mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Replace boilerplate with static method.
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package org.briarproject.bramble.util;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.util.logging.Level.FINE;
|
||||
|
||||
public class TimeUtils {
|
||||
|
||||
private static final int NANOS_PER_MILLI = 1000 * 1000;
|
||||
@@ -11,4 +15,17 @@ public class TimeUtils {
|
||||
public static long now() {
|
||||
return System.nanoTime() / NANOS_PER_MILLI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the duration of a task.
|
||||
* @param logger the logger to use
|
||||
* @param task a description of the task
|
||||
* @param start the start time of the task, as returned by {@link #now()}
|
||||
*/
|
||||
public static void logDuration(Logger logger, String task, long start) {
|
||||
if (logger.isLoggable(FINE)) {
|
||||
long duration = now() - start;
|
||||
logger.fine(task + " took " + duration + " ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user