package com.edgardleal.benchmark.example;

import com.edgardleal.benchmark.Benchmark;
import org.apache.commons.beanutils.BeanUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by edgardleal on 24/07/16.
 */
public class BeanUtilsExample implements Runnable{

  public BeanUtilsExample() {

  }

  @Override
  public void run() {
    List<Cliente> list = new ArrayList<Cliente>();
    for (int i = 0; i < Benchmark.ITERATIONS; i++) {
      Cliente cliente = new Cliente("Teste", 5, 7.7, "Test street");
      Cliente second  = new Cliente();
      try {
        second = (Cliente) BeanUtils.cloneBean(cliente);
        list.add(second);
      }catch(Exception ex) {
        ex.printStackTrace();
      }
    }
  }
}

package com.edgardleal.benchmark.example;

import com.edgardleal.benchmark.Benchmark;
import org.apache.commons.beanutils.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.lang.reflect.Field;
import org.apache.commons.lang3.StringUtils;

/**
 * Created by edgardleal on 24/07/16.
 */
public class BeanUtilsExample {

  public BeanUtilsExample() {

  }

  public void timeBeanutils() {
    List<Cliente> list = new ArrayList<Cliente>();
    for (int i = 0; i < Benchmark.ITERATIONS; i++) {
      Cliente cliente = new Cliente("Teste", 5, 7.7, "Test street");
      Cliente second  = new Cliente();
      try {
        second = (Cliente) BeanUtils.cloneBean(cliente);
        list.add(second);
      }catch(Exception ex) {
        ex.printStackTrace();
      }
    }
  }
  
  public void timeReflection() {
      List<Cliente> list = new ArrayList<Cliente>();
      for (int i = 0; i < Benchmark.ITERATIONS; i++) {
        Cliente cliente = new Cliente("Teste", 5, 7.7, "Test street");
        Cliente second = new Cliente();
        try {
          Field fields[] = Cliente.class.getDeclaredFields();
          for (Field field : fields) {
            String capitalizedName = StringUtils.capitalize(field.getName());
            Cliente.class.getDeclaredMethod("set" + capitalizedName,
                field.getType()).invoke(second,
                Cliente.class.getDeclaredMethod("get" + capitalizedName).invoke(cliente, new Class<?>[0])
            );
            list.add(second);
          }
        } catch (Exception ex) {
          ex.printStackTrace();
        }
      }
  }
}

Improve to use with chart generator
Improve to use with chart generator

Refactor to implements two methods to compare performance between beanutils and simple ( not optimized ) java reflection.