package com.edgardleal.benchmark.example;

import com.edgardleal.benchmark.Benchmark;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

/**
 * 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();
      }
    }
  }
}

package com.edgardleal.benchmark.example;

import com.edgardleal.benchmark.Benchmark;

import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

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

  public BeanUtilsExample() {

  }

  public void timeGetAndSet() {
    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();
      second.setNome(cliente.getNome());
      second.setIdade(cliente.getIdade());
      second.setSaldo(cliente.getSaldo());
      second.setEndereco(cliente.getEndereco());

      list.add(second);
    }
  }

  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();
      }
    }
  }
}

Include get and set example to BeanUtilExample