Skip to content

Commit

Permalink
fix(interactive): Fix Start Time Metric in Compiler Log (#3393)
Browse files Browse the repository at this point in the history
Use `System.currentTimeMillis()` to obtain the start time of a query
execution, instead of `System.nanoTime()`. The latter should only be
used to calculate elapsed time and is not related to any other notion of
system or wall-clock time.
  • Loading branch information
shirly121 authored Dec 1, 2023
1 parent 901b743 commit 300d921
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@

package com.alibaba.graphscope.gremlin.plugin;

import com.alibaba.graphscope.gremlin.Utils;
import com.codahale.metrics.Timer;

import java.util.concurrent.TimeUnit;

// collect metrics per gremlin query
public class MetricsCollector {
private final Timer.Context timeContext;
private long startMillis;
private final long startMillis;
private long elapsedMillis;

public MetricsCollector(Timer timer) {
this.timeContext = timer.time();
this.startMillis = System.currentTimeMillis();
}

public long getStartMillis() {
Expand All @@ -40,9 +40,6 @@ public long getElapsedMillis() {
}

public void stop() {
this.startMillis =
TimeUnit.NANOSECONDS.toMillis(
Utils.getFieldValue(Timer.Context.class, timeContext, "startTime"));
this.elapsedMillis = TimeUnit.NANOSECONDS.toMillis(timeContext.stop());
}
}

0 comments on commit 300d921

Please sign in to comment.