Methods Summary |
---|
private void | delete(org.hibernate.classic.Session s)
s.delete("from Simple s");
s.flush();
s.connection().commit();
|
public java.lang.String[] | getMappings()
return new String[] { "legacy/Simple.hbm.xml" };
|
public static void | main(java.lang.String[] args)
TestRunner.run( suite() );
|
private void | prepare(org.hibernate.classic.Session s, Simple[] simples, java.io.Serializable[] ids, int N)
for ( int i=0; i<N; i++ ) {
s.save( simples[i], ids[i] );
}
s.flush();
s.connection().commit();
|
public static junit.framework.Test | suite()
return new TestSuite(NewPerformanceTest.class);
|
public void | testPerformance()
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);
}
Session s = openSession();
prepare(s, simples, ids, n);
s.close();
long find = 0;
long flush = 0;
for ( int i=0; i<100; i++ ) {
s = openSession();
long time = System.currentTimeMillis();
List list = s.createQuery("from Simple s where not s.name='osama bin laden' and s.other is null").list();
find += System.currentTimeMillis() - time;
assertTrue( list.size()==n );
time = System.currentTimeMillis();
s.flush();
flush += System.currentTimeMillis() - time;
time = System.currentTimeMillis();
s.connection().commit();
find += System.currentTimeMillis() - time;
s.close();
}
System.out.println( "Objects: " + n + " - find(): " + find + "ms / flush(): " + flush + "ms / Ratio: " + ( (float) flush )/find );
System.out.println( "Objects: " + n + " flush time per object: " + flush / 100.0 / n );
System.out.println( "Objects: " + n + " load time per object: " + find / 100.0 / n );
s = openSession();
delete(s);
s.close();
}
|