use of org.springframework.util.StopWatch in project spring-integration by spring-projects.
the class DefaultHttpHeaderMapperFromMessageOutboundTests method perf.
@Test
@Ignore
public void perf() throws ParseException {
HeaderMapper<HttpHeaders> mapper = DefaultHttpHeaderMapper.outboundMapper();
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.set("Transfer-Encoding", "chunked");
httpHeaders.set("X-Transfer-Encoding1", "chunked");
httpHeaders.set("X-Transfer-Encoding2", "chunked");
httpHeaders.set("X-Transfer-Encoding3", "chunked");
httpHeaders.set("X-Transfer-Encoding4", "chunked");
httpHeaders.set("X-Transfer-Encoding5", "chunked");
httpHeaders.set("X-Transfer-Encoding6", "chunked");
httpHeaders.set("X-Transfer-Encoding7", "chunked");
StopWatch watch = new StopWatch();
watch.start();
for (int i = 0; i < 100000; i++) {
mapper.toHeaders(httpHeaders);
}
watch.stop();
}
use of org.springframework.util.StopWatch in project spring-integration by spring-projects.
the class ConfigurableMongoDbMessageGroupStoreTests method messageGroupStoreLazyLoadPerformance.
@Test
@Ignore("The performance test. Enough slow. Also needs the release strategy changed to size() == 1000")
@MongoDbAvailable
public void messageGroupStoreLazyLoadPerformance() throws Exception {
cleanupCollections(new SimpleMongoDbFactory(new MongoClient(), "test"));
StopWatch watch = new StopWatch("Lazy-Load Performance");
int sequenceSize = 1000;
performLazyLoadEagerTest(watch, sequenceSize, true);
performLazyLoadEagerTest(watch, sequenceSize, false);
// System. out .println(watch.prettyPrint()); // checkstyle
}
use of org.springframework.util.StopWatch in project spring-integration by spring-projects.
the class ExponentialMovingAverageRateTests method testRate.
@Test
// tolerance needed is too dependent on hardware
@Ignore
public void testRate() {
ExponentialMovingAverageRate rate = new ExponentialMovingAverageRate(1, 60, 10);
int count = 1000000;
StopWatch watch = new StopWatch();
watch.start();
for (int i = 0; i < count; i++) {
rate.increment();
}
watch.stop();
double calculatedRate = count / (double) watch.getTotalTimeMillis() * 1000;
assertEquals(calculatedRate, rate.getMean(), 4000000);
}
use of org.springframework.util.StopWatch in project spring-integration by spring-projects.
the class ConnectionFactoryShutDownTests method testShutdownDoesntDeadlock.
@Test
public void testShutdownDoesntDeadlock() throws Exception {
final AbstractConnectionFactory factory = new AbstractConnectionFactory(0) {
@Override
public TcpConnection getConnection() {
return null;
}
};
factory.setActive(true);
Executor executor = factory.getTaskExecutor();
final CountDownLatch latch1 = new CountDownLatch(1);
final CountDownLatch latch2 = new CountDownLatch(1);
executor.execute(() -> {
latch1.countDown();
try {
while (true) {
factory.getTaskExecutor();
Thread.sleep(10);
}
} catch (MessagingException e1) {
} catch (InterruptedException e2) {
Thread.currentThread().interrupt();
}
latch2.countDown();
});
assertTrue(latch1.await(10, TimeUnit.SECONDS));
StopWatch watch = new StopWatch();
watch.start();
factory.stop();
watch.stop();
assertTrue("Expected < 10000, was: " + watch.getLastTaskTimeMillis(), watch.getLastTaskTimeMillis() < 10000);
assertTrue(latch1.await(10, TimeUnit.SECONDS));
}
use of org.springframework.util.StopWatch in project spring-integration by spring-projects.
the class JdbcLockRegistryDifferentClientTests method testExclusiveAccess.
@Test
public void testExclusiveAccess() throws Exception {
DefaultLockRepository client1 = new DefaultLockRepository(dataSource);
client1.afterPropertiesSet();
final DefaultLockRepository client2 = new DefaultLockRepository(dataSource);
client2.afterPropertiesSet();
Lock lock1 = new JdbcLockRegistry(client1).obtain("foo");
final BlockingQueue<Integer> data = new LinkedBlockingQueue<>();
final CountDownLatch latch1 = new CountDownLatch(1);
lock1.lockInterruptibly();
new SimpleAsyncTaskExecutor().execute(() -> {
Lock lock2 = new JdbcLockRegistry(client2).obtain("foo");
try {
latch1.countDown();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
lock2.lockInterruptibly();
stopWatch.stop();
data.add(4);
Thread.sleep(10);
data.add(5);
Thread.sleep(10);
data.add(6);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
lock2.unlock();
}
});
assertTrue(latch1.await(10, TimeUnit.SECONDS));
data.add(1);
Thread.sleep(100);
data.add(2);
Thread.sleep(100);
data.add(3);
lock1.unlock();
for (int i = 0; i < 6; i++) {
Integer integer = data.poll(10, TimeUnit.SECONDS);
assertNotNull(integer);
assertEquals(i + 1, integer.intValue());
}
}
Aggregations