jdk.nashorn.internal.{codegen.CompilationPhase|runtime.Timing} should use System.nanoTime

XMLWordPrintable

    • b29
    • generic
    • generic

        If you look into CompilationPhase internal profiling, you will notice it uses System.currentTimeMillis for internal profiling, which limits the resolution to 1ms. If the compilation phase is faster than 1ms, then runtime.Timing will "aggregate" zero result into its accumulated statistics. Please change the uses to System.nanoTime.

        Additionally, it might be worthwhile to consider other places as well:

        $ ack-grep currentTimeMillis
        src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java
        198: final long now = System.currentTimeMillis();

        src/jdk/nashorn/internal/codegen/CompilationPhase.java
        633: startTime = System.currentTimeMillis();
        646: endTime = System.currentTimeMillis();

        src/jdk/nashorn/internal/objects/NativeDate.java
        134: this(System.currentTimeMillis());
        257: return System.currentTimeMillis();

        src/jdk/nashorn/internal/parser/Parser.java
        258: final long t0 = isTimingEnabled ? System.currentTimeMillis() : 0L;
        279: env._timing.accumulateTime(toString(), System.currentTimeMillis() - t0);
        280: log.info(end, "' in ", System.currentTimeMillis() - t0, " ms");

        src/jdk/nashorn/internal/runtime/Timing.java
        60: this.startTime = System.currentTimeMillis();
        169: final long t = System.currentTimeMillis();

              Assignee:
              Marcus Lagergren
              Reporter:
              Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: