systemml-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [systemml] xtern edited a comment on issue #862: Systemml 2526 Date.getTime() can be changed to System.currentTimeMillis()
Date Mon, 15 Apr 2019 17:24:23 GMT
xtern edited a comment on issue #862: Systemml 2526 Date.getTime() can be changed to System.currentTimeMillis()
URL: https://github.com/apache/systemml/pull/862#issuecomment-483341237
 
 
   > Hello, please see the example program.
   
   Hello! I was a little confused with your benchmarking and re-checked these results with
JMH on Ubuntu (jdk8) and found that the difference is not that significant: currentTimeMillis
faster for 0.02 nanosecond per operation (less than the measurement error).
   Anyway I think It's much better to use currentTimeMillis instead of new Date().getTime()
   ```
   Benchmark             Mode  Cnt   Score   Error  Units
   TimeTest.checkDate    avgt   10  22.733 ± 0.106  ns/op
   TimeTest.checkMillis  avgt   10  22.753 ± 0.106  ns/op
   ```
   code
   ```java
   import java.util.Date;
   import java.util.concurrent.TimeUnit;
   import org.openjdk.jmh.annotations.Benchmark;
   import org.openjdk.jmh.annotations.BenchmarkMode;
   import org.openjdk.jmh.annotations.Fork;
   import org.openjdk.jmh.annotations.Measurement;
   import org.openjdk.jmh.annotations.Mode;
   import org.openjdk.jmh.annotations.OutputTimeUnit;
   import org.openjdk.jmh.annotations.Scope;
   import org.openjdk.jmh.annotations.State;
   import org.openjdk.jmh.annotations.Threads;
   import org.openjdk.jmh.annotations.Warmup;
   import org.openjdk.jmh.runner.Runner;
   import org.openjdk.jmh.runner.RunnerException;
   import org.openjdk.jmh.runner.options.Options;
   import org.openjdk.jmh.runner.options.OptionsBuilder;
   
   @BenchmarkMode(Mode.AverageTime)
   @Fork(value = 1, jvmArgsAppend = {"-Xms3g", "-Xmx3g", "-server", "-XX:+AggressiveOpts"})
   @OutputTimeUnit(TimeUnit.NANOSECONDS)
   @State(Scope.Benchmark)
   @Threads(1)
   @Warmup(iterations = 10)
   @Measurement(iterations = 20)
   public class TimeTest {
       @Benchmark
       public long checkDate() {
           return new Date().getTime();
       }
   
       @Benchmark
       public long checkMillis() {
           return System.currentTimeMillis();
       }
   
       public static void main(String[] args) throws RunnerException {
           final Options options = new OptionsBuilder()
               .include(TimeTest.class.getSimpleName())
               .build();
   
           new Runner(options).run();
       }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message