use of org.apache.geode.internal.util.StopWatch in project geode by apache.
the class LoggingPerformanceTestCase method performCountBasedIsEnabledTest.
protected long performCountBasedIsEnabledTest(final PerformanceLogger perfLogger) {
System.out.println("\nBeginning " + getUniqueName());
final StopWatch stopWatch = new StopWatch(true);
for (int sets = 0; sets < LOG_SETS; sets++) {
for (int count = 0; count < LOG_REPETITIONS_PER_SET; count++) {
perfLogger.isEnabled();
}
}
stopWatch.stop();
final long millis = stopWatch.elapsedTimeMillis();
final long seconds = millis / 1000;
final long minutes = seconds / 60;
System.out.println(getUniqueName() + " performCountBasedIsEnabledTest");
System.out.println("Number of isEnabled statements: " + LOG_SETS * LOG_REPETITIONS_PER_SET);
System.out.println("Total elapsed time in millis: " + millis);
System.out.println("Total elapsed time in seconds: " + seconds);
System.out.println("Total elapsed time in minutes: " + minutes);
return millis;
}
use of org.apache.geode.internal.util.StopWatch in project geode by apache.
the class LoggingPerformanceTestCase method performCountBasedLoggingTest.
protected long performCountBasedLoggingTest(final PerformanceLogger perfLogger) {
System.out.println("\nBeginning " + getUniqueName());
final StopWatch stopWatch = new StopWatch(true);
for (int sets = 0; sets < LOG_SETS; sets++) {
for (int count = 0; count < LOG_REPETITIONS_PER_SET; count++) {
perfLogger.log(message);
// fail("KIRK");
}
}
stopWatch.stop();
final long millis = stopWatch.elapsedTimeMillis();
final long seconds = millis / 1000;
final long minutes = seconds / 60;
System.out.println(getUniqueName() + " performCountBasedLoggingTest");
System.out.println("Number of log statements: " + LOG_SETS * LOG_REPETITIONS_PER_SET);
System.out.println("Total elapsed time in millis: " + millis);
System.out.println("Total elapsed time in seconds: " + seconds);
System.out.println("Total elapsed time in minutes: " + minutes);
return millis;
}
use of org.apache.geode.internal.util.StopWatch in project geode by apache.
the class TXJUnitTest method waitForKeys.
private static void waitForKeys(final Index idx, final int expectedKeys) {
// DistributedTestCase.WaitCriterion wc = new DistributedTestCase.WaitCriterion() {
// String excuse;
// public boolean done() {
// return idx.getStatistics().getNumberOfKeys() == expectedKeys;
// }
//
// public String description() {
// return "expectedKeys " + expectedKeys + " but got this "
// + idx.getStatistics().getNumberOfKeys();
// }
// };
// DistributedTestCase.waitForCriterion(wc, 15 * 1000, 20, true);
boolean done = false;
try {
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 15 * 1000; done = (idx.getStatistics().getNumberOfKeys() == expectedKeys)) {
Thread.sleep(20);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
assertTrue("expectedKeys " + expectedKeys + " but got this " + idx.getStatistics().getNumberOfKeys(), done);
}
use of org.apache.geode.internal.util.StopWatch in project geode by apache.
the class AbstractLauncherIntegrationTestCase method assertEventuallyFalse.
protected static void assertEventuallyFalse(final String message, final Callable<Boolean> callable, final int timeout, final int interval) throws Exception {
boolean done = false;
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < timeout; done = (!callable.call())) {
Thread.sleep(interval);
}
assertTrue(message, done);
}
use of org.apache.geode.internal.util.StopWatch in project geode by apache.
the class ProxyJUnitTest method testExpiration.
/**
* Make sure a proxy region expiration behaves as expected
*/
@Test
public void testExpiration() throws Exception {
System.setProperty(LocalRegion.EXPIRY_MS_PROPERTY, "true");
try {
// now make sure they don't on proxy
{
AttributesFactory af = new AttributesFactory();
af.setStatisticsEnabled(true);
af.setEntryIdleTimeout(new ExpirationAttributes(1, ExpirationAction.LOCAL_INVALIDATE));
af.setEntryTimeToLive(new ExpirationAttributes(2, ExpirationAction.LOCAL_DESTROY));
af.setDataPolicy(DataPolicy.EMPTY);
try {
af.create();
fail("expected IllegalStateException");
} catch (IllegalStateException expected) {
}
}
// make sure regionIdleTimeout works on proxy
{
CacheListener cl1 = new CacheListenerAdapter() {
public void afterRegionDestroy(RegionEvent e) {
clInvokeCount++;
}
public void afterRegionInvalidate(RegionEvent e) {
clInvokeCount++;
}
};
AttributesFactory af = new AttributesFactory();
af.setStatisticsEnabled(true);
final int EXPIRE_MS = 500;
af.setRegionIdleTimeout(new ExpirationAttributes(EXPIRE_MS, ExpirationAction.LOCAL_DESTROY));
af.addCacheListener(cl1);
af.setDataPolicy(DataPolicy.EMPTY);
clearCallbackState();
Region r = this.c.createRegion("rEMPTY", af.create());
assertTrue(clInvokeCount == 0);
r.put("key", "value");
long endTime = System.currentTimeMillis() + (EXPIRE_MS * 2);
do {
r.get("key");
} while (System.currentTimeMillis() < endTime);
assertEquals(0, this.clInvokeCount);
Thread.sleep(EXPIRE_MS * 2);
boolean done = false;
try {
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 1000; done = (ProxyJUnitTest.this.clInvokeCount == 1)) {
Thread.sleep(200);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
assertTrue("waiting for invocation", done);
}
// make sure regionTimeToLive works on proxy
{
CacheListener cl1 = new CacheListenerAdapter() {
public void afterRegionDestroy(RegionEvent e) {
clInvokeCount++;
}
public void afterRegionInvalidate(RegionEvent e) {
clInvokeCount++;
}
};
AttributesFactory af = new AttributesFactory();
af.setStatisticsEnabled(true);
final int EXPIRE_MS = 500;
af.setRegionTimeToLive(new ExpirationAttributes(EXPIRE_MS, ExpirationAction.LOCAL_DESTROY));
af.addCacheListener(cl1);
af.setDataPolicy(DataPolicy.EMPTY);
clearCallbackState();
Region r = this.c.createRegion("rEMPTY", af.create());
assertTrue(clInvokeCount == 0);
r.put("key", "value");
long endTime = System.currentTimeMillis() + (EXPIRE_MS * 2);
do {
r.put("key", "value");
} while (System.currentTimeMillis() < endTime);
assertEquals(0, this.clInvokeCount);
Thread.sleep(EXPIRE_MS * 2);
boolean done = false;
try {
for (StopWatch time = new StopWatch(true); !done && time.elapsedTimeMillis() < 1000; done = (ProxyJUnitTest.this.clInvokeCount == 1)) {
Thread.sleep(200);
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
assertTrue("waiting for invocation", done);
}
} finally {
System.clearProperty(LocalRegion.EXPIRY_MS_PROPERTY);
assertEquals(null, System.getProperty(LocalRegion.EXPIRY_MS_PROPERTY));
}
}
Aggregations