You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemml.apache.org by GitBox <gi...@apache.org> on 2019/04/15 17:24:23 UTC
[GitHub] [systemml] xtern edited a comment on issue #862: Systemml 2526
Date.getTime() can be changed to System.currentTimeMillis()
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