use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class SimplePerfTest method debugDisabledByLevel.
@Test
public void debugDisabledByLevel() {
System.gc();
final Timer timer = new Timer("DebugDisabled", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
logger.isEnabled(Level.DEBUG);
}
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 SimplePerfTest method setupClass.
@BeforeClass
public static void setupClass() {
final Configuration config = LoggerContext.getContext().getConfiguration();
if (!DefaultConfiguration.DEFAULT_NAME.equals(config.getName())) {
System.out.println("Configuration was " + config.getName());
LoggerContext.getContext().start(new DefaultConfiguration());
}
for (int i = 0; i < WARMUP; ++i) {
overhead();
}
System.gc();
final Timer timer = new Timer("Setup", LOOP_CNT);
timer.start();
for (int i = 0; i < (LOOP_CNT / 150); ++i) {
overhead();
}
timer.stop();
maxTime = timer.getElapsedNanoTime();
System.gc();
System.out.println(timer.toString());
}
use of org.apache.logging.log4j.Timer in project logging-log4j2 by apache.
the class SimplePerfTest method debugDisabled.
@Test
public void debugDisabled() {
System.gc();
final Timer timer = new Timer("DebugDisabled", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
logger.isDebugEnabled();
}
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 ThreadedPerfTest method debugLogger.
@Test
public void debugLogger() {
final Timer timer = new Timer("DebugLogger", LOOP_CNT * THREADS);
final Runnable runnable = new DebugLoggerRunnable();
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 MessageFormatsPerfTest method testFormattedParameterizedPerf.
@Test
public void testFormattedParameterizedPerf() {
final String testMsg = "Test message {} {}";
final Timer timer = new Timer("FormattedParameterized", LOOP_CNT);
timer.start();
for (int i = 0; i < LOOP_CNT; ++i) {
final FormattedMessage msg = new FormattedMessage(testMsg, "Apache", "Log4j");
array[i] = msg.getFormattedMessage();
}
timer.stop();
formattedTime = timer.getElapsedNanoTime();
System.out.println(timer.toString());
}
Aggregations