use of io.narayana.perf.Measurement in project narayana by jbosstm.
the class PerformanceTest method measureThroughput.
// 2PC commit
@Test
public void measureThroughput() throws Exception {
String info = USE_SPDY ? "SPDY" : USE_SSL ? "SSL" : USE_UNDERTOW ? "UTOW" : "none";
String metricName = getClass().getName() + "_measureThroughput_" + info;
int callCount = 1000;
int warmUpCount = 10;
int threadCount = 10;
int batchSize = 50;
Measurement measurement = new Measurement.Builder(metricName).maxTestTime(0L).numberOfCalls(callCount).numberOfThreads(threadCount).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(new RTSWorker());
Assert.assertEquals(0, measurement.getNumberOfErrors());
Assert.assertFalse(measurement.getInfo(), measurement.shouldFail());
}
use of io.narayana.perf.Measurement in project narayana by jbosstm.
the class Performance4 method test.
@Test
public void test() {
int threadCount = 10;
int batchSize = 100;
int warmUpCount = 0;
int numberOfTransactions = threadCount * batchSize;
arjPropertyManager.getCoordinatorEnvironmentBean().setCommitOnePhase(false);
arjPropertyManager.getObjectStoreEnvironmentBean().setObjectStoreType(TwoPhaseVolatileStore.class.getName());
Measurement measurement = new Measurement.Builder(getClass().getName() + "_test1").maxTestTime(0L).numberOfCalls(numberOfTransactions).numberOfThreads(threadCount).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(worker);
Assert.assertEquals(0, measurement.getNumberOfErrors());
Assert.assertFalse(measurement.getInfo(), measurement.shouldFail());
System.out.printf("%s%n", measurement.getInfo());
System.out.println("time for " + numberOfTransactions + " write transactions is " + measurement.getTotalMillis());
System.out.println("number of transactions: " + numberOfTransactions);
System.out.println("throughput: " + (float) (numberOfTransactions / (measurement.getTotalMillis() / 1000.0)));
}
use of io.narayana.perf.Measurement in project narayana by jbosstm.
the class PerformanceTestCommitMarkableResource method doTest.
public void doTest(final Handler xaHandler, String testName) throws Exception {
String fullTestName = getClass().getName() + testName;
Worker<Void> worker = new Worker<Void>() {
javax.transaction.TransactionManager tm = null;
@Override
public void init() {
tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
}
@Override
public void fini() {
// totalExecuted.addAndGet(success);
}
@Override
public void finishWork(Measurement<Void> measurement) {
try {
xaHandler.finishWork();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public Void doWork(Void context, int batchSize, Measurement<Void> measurement) {
for (int i = 0; i < batchSize; i++) {
try {
tm.begin();
tm.getTransaction().enlistResource(new DummyXAResource());
xaHandler.enlistResource(tm.getTransaction());
tm.commit();
// System.out.println("done");
totalExecuted.incrementAndGet();
} catch (SQLException e) {
measurement.incrementErrorCount();
if (measurement.getNumberOfErrors() == 1) {
System.err.println("boom");
e.printStackTrace();
if (e.getCause() != null) {
e.getCause().printStackTrace();
}
SQLException nextException = e.getNextException();
while (nextException != null) {
nextException.printStackTrace();
nextException = nextException.getNextException();
}
Throwable[] suppressed = e.getSuppressed();
for (int j = 0; j < suppressed.length; j++) {
suppressed[j].printStackTrace();
}
try {
tm.rollback();
} catch (IllegalStateException | SecurityException | SystemException e1) {
e1.printStackTrace();
fail("Problem with transaction");
}
}
} catch (NotSupportedException | SystemException | IllegalStateException | RollbackException | SecurityException | HeuristicMixedException | HeuristicRollbackException e) {
measurement.incrementErrorCount();
e.printStackTrace();
fail("Problem with transaction");
}
}
return context;
}
};
// TODO if non zero then make sure the db is reset after the warm up loop
int warmUpCount = 0;
int batchSize = 50;
int threadCount = 20;
Measurement measurement = new Measurement.Builder(fullTestName).maxTestTime(0L).numberOfCalls(batchSize * threadCount).numberOfThreads(threadCount).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(worker, worker);
System.out.printf("%s%n", measurement.getInfo());
System.out.println(new Date() + " Number of transactions: " + totalExecuted.intValue());
long additionalCleanuptime = xaHandler.postRunCleanup(measurement.getNumberOfMeasurements(), measurement.getNumberOfCalls(), measurement.getNumberOfThreads());
long timeInMillis = measurement.getTotalMillis() + additionalCleanuptime;
long throughput = Math.round((totalExecuted.intValue() / (timeInMillis / 1000d)));
System.out.println(" Total transactions: " + totalExecuted.intValue());
System.out.println(" Total time millis: " + timeInMillis);
System.out.println(" Average transaction time: " + timeInMillis / totalExecuted.intValue());
System.out.println(" Transactions per second: " + throughput);
xaHandler.checkFooSize(measurement.getNumberOfMeasurements(), measurement.getBatchSize(), measurement.getNumberOfThreads());
Assert.assertEquals(0, measurement.getNumberOfErrors());
Assert.assertFalse(measurement.getInfo(), measurement.shouldFail());
}
use of io.narayana.perf.Measurement in project narayana by jbosstm.
the class OnePhase2PCPerformanceDefaultUnitTest method test.
@Test
public void test() {
int warmUpCount = 0;
int numberOfThreads = 10;
int batchSize = 1000;
int numberOfTransactions = numberOfThreads * batchSize;
Measurement measurement = new Measurement.Builder(getClass().getName() + "_test1").maxTestTime(0L).numberOfCalls(numberOfTransactions).numberOfThreads(numberOfThreads).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(worker, worker);
System.out.printf("%s%n", measurement.getInfo());
Assert.assertEquals(0, measurement.getNumberOfErrors());
Assert.assertFalse(measurement.getInfo(), measurement.shouldFail());
long timeTaken = measurement.getTotalMillis();
System.out.println("ObjectStore used: " + arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreType());
System.out.println("time for " + numberOfTransactions + " write transactions is " + timeTaken);
System.out.println("number of transactions: " + numberOfTransactions);
System.out.println("throughput: " + (float) (numberOfTransactions / (timeTaken / 1000.0)));
}
use of io.narayana.perf.Measurement in project narayana by jbosstm.
the class OnePhase2PCPerformanceVolatileUnitTest method test.
@Test
public void test() {
int warmUpCount = 0;
int numberOfThreads = 10;
int batchSize = 1000;
int numberOfTransactions = numberOfThreads * batchSize;
Measurement measurement = new Measurement.Builder(getClass().getName() + "_test1").maxTestTime(0L).numberOfCalls(numberOfTransactions).numberOfThreads(numberOfThreads).batchSize(batchSize).numberOfWarmupCalls(warmUpCount).build().measure(worker, worker);
System.out.printf("%s%n", measurement.getInfo());
Assert.assertEquals(0, measurement.getNumberOfErrors());
Assert.assertFalse(measurement.getInfo(), measurement.shouldFail());
long timeTaken = measurement.getTotalMillis();
System.out.println("ObjectStore used: " + arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreType());
System.out.println("time for " + numberOfTransactions + " write transactions is " + timeTaken);
System.out.println("number of transactions: " + numberOfTransactions);
System.out.println("throughput: " + (float) (numberOfTransactions / (timeTaken / 1000.0)));
}
Aggregations