use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class MessageFormatsPerfTest method testParameterizedPerf.
@Test
public void testParameterizedPerf() {
final String testMsg = "Test message {} {}";
final Timer timer = new Timer("Parameterized", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
final ParameterizedMessage msg = new ParameterizedMessage(testMsg, "Apache", "Log4j");
array[i] = msg.getFormattedMessage();
}
timer.stop();
paramTime = timer.getElapsedNanoTime();
System.out.println(timer.toString());
}
use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class MessageFormatsPerfTest method testStringPerf.
@Test
public void testStringPerf() {
final String testMsg = "Test message %1s %2s";
final Timer timer = new Timer("StringFormat", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
final StringFormattedMessage msg = new StringFormattedMessage(testMsg, "Apache", "Log4j");
array[i] = msg.getFormattedMessage();
}
timer.stop();
stringTime = timer.getElapsedNanoTime();
System.out.println(timer.toString());
}
use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class ThreadedPerfTest method debugDisabled.
@Test
public void debugDisabled() {
final Timer timer = new Timer("DebugDisabled", LOOP_CNT * THREADS);
final Runnable runnable = new DebugDisabledRunnable();
final ExecutorService pool = Executors.newFixedThreadPool(THREADS);
timer.start();
for (int i = 0; i < THREADS; ++i) {
pool.execute(runnable);
}
pool.shutdown();
timer.stop();
System.out.println(timer.toString());
}
use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class SimplePerfTest method debugLogger.
@Test
public void debugLogger() {
System.gc();
final Timer timer = new Timer("DebugLogger", LOOP_CNT);
final String msg = "This is a test";
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
logger.debug(msg);
}
timer.stop();
System.out.println(timer.toString());
assertTrue("Timer exceeded max time of " + maxTime, maxTime > timer.getElapsedNanoTime());
}
use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class MessageFormatsPerfTest method testMessageFormatPerf.
@Test
public void testMessageFormatPerf() {
final String testMsg = "Test message {0} {1}";
final Timer timer = new Timer("MessageFormat", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
final MessageFormatMessage msg = new MessageFormatMessage(testMsg, "Apache", "Log4j");
array[i] = msg.getFormattedMessage();
}
timer.stop();
msgFormatTime = timer.getElapsedNanoTime();
System.out.println(timer.toString());
}
Aggregations