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

@@ -177,16 +177,93 @@
 il.List;
+%0Aimport java.lang.reflect.Field;%0Aimport org.apache.commons.lang3.StringUtils;
 %0A%0A/**%0A *
@@ -336,27 +336,8 @@
 ple 
-implements Runnable
 %7B%0A%0A 
@@ -377,35 +377,33 @@
 %0A%0A  
-@Override%0A  public void run
+public void timeBeanutils
 () %7B
@@ -787,10 +787,825 @@
   %7D%0A  %7D%0A
+  %0A  public void timeReflection() %7B%0A      List%3CCliente%3E list = new ArrayList%3CCliente%3E();%0A      for (int i = 0; i %3C Benchmark.ITERATIONS; i++) %7B%0A        Cliente cliente = new Cliente(%22Teste%22, 5, 7.7, %22Test street%22);%0A        Cliente second = new Cliente();%0A        try %7B%0A          Field fields%5B%5D = Cliente.class.getDeclaredFields();%0A          for (Field field : fields) %7B%0A            String capitalizedName = StringUtils.capitalize(field.getName());%0A            Cliente.class.getDeclaredMethod(%22set%22 + capitalizedName,%0A                field.getType()).invoke(second,%0A                Cliente.class.getDeclaredMethod(%22get%22 + capitalizedName).invoke(cliente, new Class%3C?%3E%5B0%5D)%0A            );%0A            list.add(second);%0A          %7D%0A        %7D catch (Exception ex) %7B%0A          ex.printStackTrace();%0A        %7D%0A      %7D%0A  %7D%0A
 %7D%0A

Improve to use with chart generator