}
public void testThreaded(int numthreads, TXTYPE txtype) throws InterruptedException {
// create document pool
ODatabaseDocumentPool pool = new ODatabaseDocumentPool(DBURI, DBUSR, DBPWD);
pool.setup(100, 200);
// create the schema for the test class if it doesn't exist
ODatabaseDocumentTx db = pool.acquire();
try {
OSchema schema = db.getMetadata().getSchema();
if (!schema.existsClass(CLASSNAME)) {
OClass oc = schema.createClass(CLASSNAME);
oc.createProperty(PROPKEY, OType.STRING);
oc.setStrictMode(true);
schema.save();
}
} finally {
db.close();
}
// create threads and execute
try {
// create threads, put into list
ArrayList<RunTest> threads = new ArrayList<RunTest>(1000);
for (int numth = 0; numth < numthreads; numth++) {
threads.add(new RunTest(pool, txtype));
}
// run test: start each thread and wait for all threads to complete with join
long a = System.currentTimeMillis();
for (RunTest t : threads) {
t.start();
}
for (RunTest t : threads) {
t.join();
}
long b = System.currentTimeMillis();
// collect from each thread
int savesum = 0;
int txnsum = 0;
for (RunTest t : threads) {
t.printStats();
savesum += t.getTotalSaves();
txnsum += t.getTotalTxns();
}
// print out cummulative stats
double secs = 1.0E-3D * (b - a);
System.out.printf("TOTAL: [%4.2f secs %d tx, %d save] %.2f tx/sec %.2f save/sec \n", secs, txnsum, savesum, txnsum / secs,
savesum / secs);
} finally {
pool.close();
}
}