reef-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Julia Wang (QIUHE)" <Qiuhe.W...@microsoft.com>
Subject Adding LoggingScope for Java REEF
Date Sat, 18 Oct 2014 00:35:59 GMT
To measure the performance at function and code block level, I would like to add a new class
LoggingScope in REEF, similar to what we have in .Net version.

For any specified code block, the object of the LoggingScope will start measure the time until
the block  exists. It will log the duration in millisecond in the end.

This class implements java.lang.AutoCloseable. For the usage, we can use  Automatic Resource
Management using try keyword for the code block.

Example is
  final class AllocatedEvaluatorHandler implements EventHandler<AllocatedEvaluator>
{
    @Override
    public void onNext(final AllocatedEvaluator allocatedEvaluator) {
      try (LoggingScope ls = new LoggingScope(LOG, "JobDriver::AllocatedEvaluatorHandler"))
{
        synchronized (JobDriver.this) {
          perfLogger.logTime("JobDriver::AllocatedEvaluatorHandler.OnNext");
          if (JobDriver.this.nCLREvaluators > 0) {
            JobDriver.this.submitEvaluator(allocatedEvaluator, EvaluatorType.CLR);
            JobDriver.this.nCLREvaluators--;
          }
        }
      }
}

The result will be logged as:

START:JobDriver::AllocatedEvaluatorHandler on Fri Oct 17 17:28:13 PDT 2014
END:JobDriver::AllocatedEvaluatorHandler on Fri Oct 17 17:28:16 PDT 2014 Duration=2839

The log level can be defined as FINE or FINEST up to what we want. The try block can be at
code pieces.

Let me know if you have feedbacks.

Thanks,
Julia

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message