for ( int n=2; n<4000; n*=2 ) { Simple[] simples = new Simple[n]; Serializable[] ids = new Serializable[n]; for ( int i=0; i<n; i++ ) { simples[i] = new Simple(); simples[i].init(); simples[i].setCount(i); ids[i] = new Long(i); } //Now do timings Session s = openSession(); long time = System.currentTimeMillis(); hibernate(s, simples, ids, n, "h1"); long hiber = System.currentTimeMillis() - time; s.close(); s = openSession(); time = System.currentTimeMillis(); hibernate(s, simples, ids, n, "h2"); hiber += System.currentTimeMillis() - time; s.close(); s = openSession(); time = System.currentTimeMillis(); hibernate(s, simples, ids, n, "h2"); hiber += System.currentTimeMillis() - time; s.close(); System.out.println( "Objects: " + n + " - Hibernate: " + hiber ); } System.gc();
Simple[] simples = new Simple[n]; Serializable[] ids = new Serializable[n]; for ( int i=0; i<n; i++ ) { simples[i] = new Simple(); simples[i].init(); simples[i].setCount(i); ids[i] = new Long(i); } //Now do timings Connection c = cp.getConnection(); long time = System.currentTimeMillis(); directJDBC( c, simples, ids, n, "j1" ); long jdbc = System.currentTimeMillis() - time; cp.closeConnection(c); c = cp.getConnection(); time = System.currentTimeMillis(); directJDBC( c, simples, ids, n, "j2" ); jdbc += System.currentTimeMillis() - time; cp.closeConnection(c); c = cp.getConnection(); time = System.currentTimeMillis(); directJDBC( c, simples, ids, n, "j2" ); jdbc += System.currentTimeMillis() - time; cp.closeConnection(c); System.out.println( "Objects: " + n + " Direct JDBC: " + jdbc );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/perf/org/hibernate/test/perf/PerformanceTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/perf/org/hibernate/test/perf/PerformanceTest.java
Method name: void testHibernateOnly() Method name: void testJdbcOnly()
Number of AST nodes: 25 Number of AST nodes: 23
1
for ( int n=2; n<4000; n*=2 ) {
2
			Simple[] simples = new Simple[n];
1
Simple[] simples = new Simple[n];
3
			Serializable[] ids = new Serializable[n];
2
			Serializable[] ids = new Serializable[n];
4
			for ( int i=0; i<n; i++ ) {
3
			for ( int i=0; i<n; i++ ) {
5
				simples[i] = new Simple();
4
				simples[i] = new Simple();
6
				simples[i].init();
5
				simples[i].init();
7
				simples[i].setCount(i);
6
				simples[i].setCount(i);
8
				ids[i] = new Long(i);
7
				ids[i] = new Long(i);
9
			}
8
			}
10
			//Now do timings
9
			//Now do timings
11
			Session s = openSession();
10
			Connection c = cp.getConnection();
12
			long time = System.currentTimeMillis();
11
			long time = System.currentTimeMillis();
13
			hibernate(s, simples, ids, n, "h1");
12
			directJDBC( c, simples, ids, n, "j1" );
14
			long hiber = System.currentTimeMillis() - time;
13
			long jdbc = System.currentTimeMillis() - time;
15
			s.close();
14
			cp.closeConnection(c);
16
			s = openSession();
15
			c = cp.getConnection();
17
			time = System.currentTimeMillis();
16
			time = System.currentTimeMillis();
18
			hibernate(s, simples, ids, n, "h2");
17
			directJDBC( c, simples, ids, n, "j2" );
19
			hiber += System.currentTimeMillis() - time;
18
			jdbc += System.currentTimeMillis() - time;
20
			s.close();
19
			cp.closeConnection(c);
21
			s = openSession();
20
			c = cp.getConnection();
22
			time = System.currentTimeMillis();
21
			time = System.currentTimeMillis();
23
			hibernate(s, simples, ids, n, "h2");
22
			directJDBC( c, simples, ids, n, "j2" );
24
			hiber += System.currentTimeMillis() - time;
23
			jdbc += System.currentTimeMillis() - time;
25
			s.close();
24
			cp.closeConnection(c);
26
			System.out.println( "Objects: " + n + " - Hibernate: " + hiber );
25
			System.out.println( "Objects: " + n + " 
27
		}
28
		System.gc();
26
Direct JDBC: " + jdbc );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)0.2
Clones locationClones are declared in the same class
Number of node comparisons288
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements17
    Number of unmapped statements in the first code fragment6
    Number of unmapped statements in the second code fragment6
    Time elapsed for statement mapping (ms)12.5
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    2
    Simple[] simples = new Simple[n];
    3
    Simple[] simples = new Simple[n];
    3
    Serializable[] ids = new Serializable[n];
    4
    Serializable[] ids = new Serializable[n];
    4
    for (int i = 0; i < n; i++)
    5
    for (int i = 0; i < n; i++)
    5
    simples[i] = new Simple();
    6
    simples[i] = new Simple();
    6
    simples[i].init();
    7
    simples[i].init();
    7
    simples[i].setCount(i);
    8
    simples[i].setCount(i);
    8
    ids[i] = new Long(i);
    9
    ids[i] = new Long(i);
    9
    Session s = openSession();
    9
    Session s = openSession();
    Preondition Violations
    Unmatched statement Session s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                                          
                                                                            
    10
    Connection c = cp.getConnection();
    Preondition Violations
    Unmatched statement Connection c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    10
    Connection c = cp.getConnection();
    10
    long time = System.currentTimeMillis();
    11
    long time = System.currentTimeMillis();
                                                                              
    12
    directJDBC(c, simples, ids, n, "j1");
    Preondition Violations
    Unmatched statement directJDBC(c,simples,ids,n,"j1"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12
    directJDBC(c, simples, ids, n, "j1");
    11
    hibernate(s, simples, ids, n, "h1");
    11
    hibernate(s, simples, ids, n, "h1");
    14
    cp.closeConnection(c);
    Differences
    Expression1Expression2Difference
    hibernatecloseConnectionMETHOD_INVOCATION_NAME_MISMATCH
    hibernate(s,simples,ids,n,"h1")cp.closeConnection(c)ARGUMENT_NUMBER_MISMATCH
    cpMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression hibernate(s,simples,ids,n,"h1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h1") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    Expression hibernate(s,simples,ids,n,"h1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h1") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    14
    cp.closeConnection(c);
    12
    long hiber = System.currentTimeMillis() - time;
    12
    long hiber = System.currentTimeMillis() - time;
    13
    long jdbc = System.currentTimeMillis() - time;
    Differences
    Expression1Expression2Difference
    hiberjdbcVARIABLE_NAME_MISMATCH
    13
    long jdbc = System.currentTimeMillis() - time;
    13
    s.close();
                                
    14
    s = openSession();
    14
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
                                                      
    15
    c = cp.getConnection();
    Preondition Violations
    Unmatched statement c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    15
    c = cp.getConnection();
    15
    time = System.currentTimeMillis();
    16
    time = System.currentTimeMillis();
                                                                              
    17
    directJDBC(c, simples, ids, n, "j2");
    Preondition Violations
    Unmatched statement directJDBC(c,simples,ids,n,"j2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    17
    directJDBC(c, simples, ids, n, "j2");
    16
    hibernate(s, simples, ids, n, "h2");
    16
    hibernate(s, simples, ids, n, "h2");
    19
    cp.closeConnection(c);
    Differences
    Expression1Expression2Difference
    hibernatecloseConnectionMETHOD_INVOCATION_NAME_MISMATCH
    hibernate(s,simples,ids,n,"h2")cp.closeConnection(c)ARGUMENT_NUMBER_MISMATCH
    cpMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    19
    cp.closeConnection(c);
    17
    hiber += System.currentTimeMillis() - time;
    17
    hiber += System.currentTimeMillis() - time;
    18
    jdbc += System.currentTimeMillis() - time;
    Differences
    Expression1Expression2Difference
    hiberjdbcVARIABLE_NAME_MISMATCH
    18
    jdbc += System.currentTimeMillis() - time;
    18
    s.close();
                                
    19
    s = openSession();
    19
    s = openSession();
    Preondition Violations
    Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
                                            
                                                      
    20
    c = cp.getConnection();
    Preondition Violations
    Unmatched statement c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20
    c = cp.getConnection();
    20
    time = System.currentTimeMillis();
    21
    time = System.currentTimeMillis();
                                                                              
    22
    directJDBC(c, simples, ids, n, "j2");
    Preondition Violations
    Unmatched statement directJDBC(c,simples,ids,n,"j2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22
    directJDBC(c, simples, ids, n, "j2");
    21
    hibernate(s, simples, ids, n, "h2");
    21
    hibernate(s, simples, ids, n, "h2");
    24
    cp.closeConnection(c);
    Differences
    Expression1Expression2Difference
    hibernatecloseConnectionMETHOD_INVOCATION_NAME_MISMATCH
    hibernate(s,simples,ids,n,"h2")cp.closeConnection(c)ARGUMENT_NUMBER_MISMATCH
    cpMISSING_METHOD_INVOCATION_EXPRESSION
    Preondition Violations
    Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    • Inline private method hibernate
    Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    24
    cp.closeConnection(c);
    22
    hiber += System.currentTimeMillis() - time;
    22
    hiber += System.currentTimeMillis() - time;
    23
    jdbc += System.currentTimeMillis() - time;
    Differences
    Expression1Expression2Difference
    hiberjdbcVARIABLE_NAME_MISMATCH
    23
    jdbc += System.currentTimeMillis() - time;
    23
    s.close();
                                
    24
    System.out.println("Objects: " + n + " - Hibernate: " + hiber);
    24
    System.out.println("Objects: " + n + " - Hibernate: " + hiber);
    25
    System.out.println("Objects: " + n + " Direct JDBC: " + jdbc);
    Differences
    Expression1Expression2Difference
    " - Hibernate: "" Direct JDBC: "LITERAL_VALUE_MISMATCH
    hiberjdbcVARIABLE_NAME_MISMATCH
    25
    System.out.println("Objects: " + n + " Direct JDBC: " + jdbc);
    Precondition Violations (28)
    Row Violation
    1Unmatched statement Session s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched statement Connection c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    3Unmatched statement directJDBC(c,simples,ids,n,"j1"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Expression hibernate(s,simples,ids,n,"h1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    5Expression hibernate(s,simples,ids,n,"h1") is a void method call, and thus it cannot be parameterized
    6Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    7Expression hibernate(s,simples,ids,n,"h1") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    8Expression hibernate(s,simples,ids,n,"h1") is a void method call, and thus it cannot be parameterized
    9Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    10Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    11Unmatched statement c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    12Unmatched statement directJDBC(c,simples,ids,n,"j2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    13Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    14Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    15Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    16Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    17Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    18Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    19Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    20Unmatched statement c=cp.getConnection(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    21Unmatched statement directJDBC(c,simples,ids,n,"j2"); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    22Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    23Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    24Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    25Expression hibernate(s,simples,ids,n,"h2") cannot be parameterized, because it has dependencies to/from statements that will be extracted
    26Expression hibernate(s,simples,ids,n,"h2") is a void method call, and thus it cannot be parameterized
    27Expression cp.closeConnection(c) is a void method call, and thus it cannot be parameterized
    28Clone fragment #1 returns variables , while Clone fragment #2 returns variables simples, ids