// Path: src/main/java/org/sfm/beans/SmallBenchmarkObject.java
// @Entity
// @Table(name="test_small_benchmark_object")
// public class SmallBenchmarkObject {
// 	
// 	@Id
// 	@RowMapperField(columnName="ID")
// 	private long id;
// 
// 	@RowMapperField(columnName="YEAR_STARTED")
// 	private int yearStarted;
// 	@RowMapperField(columnName = "NAME")
// 	private String name;
// 	@RowMapperField(columnName="EMAIL")
// 	private String email;
// 
// 	@Column(name="ID")
// 	public long getId() {
// 		return id;
// 	}
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 	@Column(name="NAME")
// 	public String getName() {
// 		return name;
// 	}
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	@Column(name="EMAIL")
// 	public String getEmail() {
// 		return email;
// 	}
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 	
// 	@Column(name="YEAR_STARTED")
// 	public int getYearStarted() {
// 		return yearStarted;
// 	}
// 	public void setYearStarted(int yearStarted) {
// 		this.yearStarted = yearStarted;
// 	}
// 	@Override
// 	public String toString() {
// 		return "SmallBenchmarkObject [id=" + id + ", yearStarted="
// 				+ yearStarted + ", name=" + name + ", email=" + email + "]";
// 	}
// 	
// 	
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// 
// 	@Param(value="MOCK")
// 	public DbTarget db;
// 
// 	public DataSource dataSource;
// 	
// 	@Setup
// 	public void init() throws SQLException, NamingException {
// 		dataSource = ConnectionHelper.getDataSource(db);
// 		
// 		if (db != DbTarget.MOCK) {
// 			Connection conn = dataSource.getConnection();
// 			try {
// 				ConnectionHelper.createTableAndInsertData(conn);
// 			} finally {
// 				conn.close();
// 			}
// 		}
// 	}
// 	
// 	public Connection getConnection() throws SQLException {
// 		return dataSource.getConnection();
// 	}
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/DbTarget.java
// public enum DbTarget {
// 	MOCK {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	}, HSQLDB {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.HSQLDB;
// 		}
// 	}, MYSQL {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	};
// 
// 	public abstract SQLDialect getSqlDialect();
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/LimitParam.java
// @State(Scope.Benchmark)
// public class LimitParam {
// 	@Param(value={"1", "10", "100", "1000", "10000", "100000", "1000000"})
// 	public int limit;
// }


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.NamingException;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.sfm.beans.SmallBenchmarkObject;
import org.sfm.benchmark.db.jmh.ConnectionParam;
import org.sfm.benchmark.db.jmh.DbTarget;
import org.sfm.benchmark.db.jmh.LimitParam;
import org.sfm.jdbc.JdbcMapper;
import org.sfm.jdbc.JdbcMapperFactory;
import org.sfm.reflect.asm.AsmHelper;
import org.sfm.utils.RowHandler;


	@Benchmark
	public void testQueryForEach(ConnectionParam connectionParam, LimitParam limitParam, final Blackhole blackhole) throws Exception {
		Connection conn = connectionParam.getConnection();
		try {
			PreparedStatement ps = conn.prepareStatement(JdbcMapperStaticBenchmark.SELECT_BENCHMARK_OBJ_WITH_LIMIT);
			try {
				ps.setInt(1, limitParam.limit);
				ResultSet rs = ps.executeQuery();
				mapper.forEach(rs, new RowHandler<SmallBenchmarkObject>() {
					@Override
					public void handle(SmallBenchmarkObject smallBenchmarkObject) throws Exception {
						blackhole.consume(smallBenchmarkObject);
					}
				});
			}finally {
				ps.close();
			}
		}finally {
			conn.close();
		}
	}
	
	public static void main(String[] args) throws SQLException, NamingException {
		ConnectionParam connectionParam = new ConnectionParam();
		connectionParam.db = DbTarget.HSQLDB;
		connectionParam.init();
		Connection conn = connectionParam.getConnection();
		
// Path: src/main/java/org/sfm/beans/SmallBenchmarkObject.java
// @Entity
// @Table(name="test_small_benchmark_object")
// public class SmallBenchmarkObject {
// 	
// 	@Id
// 	@RowMapperField(columnName="ID")
// 	private long id;
// 
// 	@RowMapperField(columnName="YEAR_STARTED")
// 	private int yearStarted;
// 	@RowMapperField(columnName = "NAME")
// 	private String name;
// 	@RowMapperField(columnName="EMAIL")
// 	private String email;
// 
// 	@Column(name="ID")
// 	public long getId() {
// 		return id;
// 	}
// 	public void setId(long id) {
// 		this.id = id;
// 	}
// 	@Column(name="NAME")
// 	public String getName() {
// 		return name;
// 	}
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	@Column(name="EMAIL")
// 	public String getEmail() {
// 		return email;
// 	}
// 	public void setEmail(String email) {
// 		this.email = email;
// 	}
// 	
// 	@Column(name="YEAR_STARTED")
// 	public int getYearStarted() {
// 		return yearStarted;
// 	}
// 	public void setYearStarted(int yearStarted) {
// 		this.yearStarted = yearStarted;
// 	}
// 	@Override
// 	public String toString() {
// 		return "SmallBenchmarkObject [id=" + id + ", yearStarted="
// 				+ yearStarted + ", name=" + name + ", email=" + email + "]";
// 	}
// 	
// 	
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/ConnectionParam.java
// @State(Scope.Benchmark)
// public class ConnectionParam {
// 
// 	@Param(value="MOCK")
// 	public DbTarget db;
// 
// 	public DataSource dataSource;
// 	
// 	@Setup
// 	public void init() throws SQLException, NamingException {
// 		dataSource = ConnectionHelper.getDataSource(db);
// 		
// 		if (db != DbTarget.MOCK) {
// 			Connection conn = dataSource.getConnection();
// 			try {
// 				ConnectionHelper.createTableAndInsertData(conn);
// 			} finally {
// 				conn.close();
// 			}
// 		}
// 	}
// 	
// 	public Connection getConnection() throws SQLException {
// 		return dataSource.getConnection();
// 	}
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/DbTarget.java
// public enum DbTarget {
// 	MOCK {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	}, HSQLDB {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.HSQLDB;
// 		}
// 	}, MYSQL {
// 		@Override
// 		public SQLDialect getSqlDialect() {
// 			return SQLDialect.MYSQL;
// 		}
// 	};
// 
// 	public abstract SQLDialect getSqlDialect();
// }
// 
// Path: src/main/java/org/sfm/benchmark/db/jmh/LimitParam.java
// @State(Scope.Benchmark)
// public class LimitParam {
// 	@Param(value={"1", "10", "100", "1000", "10000", "100000", "1000000"})
// 	public int limit;
// }


// Path: src/main/java/org/sfm/benchmark/db/sfm/JdbcMapperDynamicBenchmark.java
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.NamingException;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.sfm.beans.SmallBenchmarkObject;
import org.sfm.benchmark.db.jmh.ConnectionParam;
import org.sfm.benchmark.db.jmh.DbTarget;
import org.sfm.benchmark.db.jmh.LimitParam;
import org.sfm.jdbc.JdbcMapper;
import org.sfm.jdbc.JdbcMapperFactory;
import org.sfm.reflect.asm.AsmHelper;
import org.sfm.utils.RowHandler;



	@Benchmark
	public void testQueryForEach(ConnectionParam connectionParam, LimitParam limitParam, final Blackhole blackhole) throws Exception {
		Connection conn = connectionParam.getConnection();
		try {
			PreparedStatement ps = conn.prepareStatement(JdbcMapperStaticBenchmark.SELECT_BENCHMARK_OBJ_WITH_LIMIT);
			try {
				ps.setInt(1, limitParam.limit);
				ResultSet rs = ps.executeQuery();
				mapper.forEach(rs, new RowHandler<SmallBenchmarkObject>() {
					@Override
					public void handle(SmallBenchmarkObject smallBenchmarkObject) throws Exception {
						blackhole.consume(smallBenchmarkObject);
					}
				});
			}finally {
				ps.close();
			}
		}finally {
			conn.close();
		}
	}
	
	public static void main(String[] args) throws SQLException, NamingException {
		ConnectionParam connectionParam = new ConnectionParam();
		connectionParam.db = DbTarget.HSQLDB;
		connectionParam.init();
		Connection conn = connectionParam.getConnection();
		
		JdbcMapper<SmallBenchmarkObject> mapper = JdbcMapperFactory.newInstance().useAsm(false).newMapper(SmallBenchmarkObject.class);