2

JMHツールを見てみましょう。

サンプル ファイルJMHSample_03_States では、次のように述べています。

  ============================== HOW TO RUN THIS TEST: ====================================

  You are expected to see the drastic difference in shared and unshared cases,
  because you either contend for single memory location, or not. This effect
  is more articulated on large machines.

  You can run this test:

  a) Via the command line:
     $ mvn clean install
     $ java -jar target/benchmarks.jar JMHSample_03 -wi 5 -i 5 -t 4 -f 1
     (we requested 5 measurement/warmup iterations, with 4 threads, single fork)

Java 1.8.20.0 と Intel i5-4670K CPU @ 3.40GHz の私の結果

# Run complete. Total time: 00:00:24

Benchmark                                   Mode  Samples           Score  Score error  Units
o.s.JMHSample_03_States.measureShared      thrpt        5  1547894580.996  3632128.044  ops/s
o.s.JMHSample_03_States.measureUnshared    thrpt        5  1571371998.011  6150584.658  ops/s

「劇的な違い」とは?measureShared (1547894580) と measureUnshared (1571371998) の差が 2% 未満

4

0 に答える 0