1
Tél : +33 (0)1 58 56 10 00
Fax : +33 (0)1 58 56 10 01
www.octo.com© OCTO 2014
50, avenue des Champs-Elysées
75008 Paris ...
2
Henri Tremblay
OCTO Technology
Senior Architect
R&D manager
Performance specialist
EasyMock lead developer
Objenesis lea...
3
WHAT IS IT?
4
JAPEX
5
6
Hotspot optimizations
compiler tactics
delayed compilation
tiered compilation
on-stack replacement
delayed reoptimizatio...
7
vs
8
CODE
9
JMH
=
Java Microbenchmarking Harness
10
11
http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/
JMHSample_01_Hell...
12
HOW DOES IT
WORK?
13
CODE
14
Intel Core i7-4500U
1.8 GHz (to 2.5 GHz with Intel Turbo Boost)
1 800 000 000 cycles per second
3 600 000 000 instructi...
15
CODE
16
17
@Setup / @TearDown
BlackHole
@Group / @GroupThreads
@CompilerControl(CompilerControl.Mode.DONT_INLINE)
BlackHole.consum...
18
CODE
19
20
21
22
EasyMock Mockito
Interface mocking 167 ns/op 4080 ns/op
Class mocking 8588 ns/op 4273 ns/op
23
Bottomline
I need to investigate a bit
You need to be cautious!
and be suspicious of any benchmark you read
Examples:
•...
24
http://perfug.github.io
/
+Henri Tremblay
@henri_tremblay
htremblay@octo.com
http://brownbaglunch.fr
Prochain SlideShare
Chargement dans…5
×

Microbenchmarking with JMH

1 639 vues

Publié le

Microbenchmark basic and lesson about being suspicious about benchmark. The source code is here: https://github.com/henri-tremblay/microbenchmarkingwithjmh

  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

Microbenchmarking with JMH

  1. 1. 1 Tél : +33 (0)1 58 56 10 00 Fax : +33 (0)1 58 56 10 01 www.octo.com© OCTO 2014 50, avenue des Champs-Elysées 75008 Paris - FRANCE Microbenchmarking with JMH
  2. 2. 2 Henri Tremblay OCTO Technology Senior Architect R&D manager Performance specialist EasyMock lead developer Objenesis lead developer
  3. 3. 3 WHAT IS IT?
  4. 4. 4 JAPEX
  5. 5. 5
  6. 6. 6 Hotspot optimizations compiler tactics delayed compilation tiered compilation on-stack replacement delayed reoptimization program dependence graph representation static single assignment representation speculative (profile-based) techniques optimistic nullness assertions optimistic type assertions optimistic type strengthening optimistic array length strengthening untaken branch pruning optimistic N-morphic inlining branch frequency prediction call frequency prediction proof-based techniques exact type inference memory value inference memory value tracking constant folding reassociation operator strength reduction null check elimination type test strength reduction type test elimination algebraic simplification common subexpression elimination integer range typing flow-sensitive rewrites conditional constant propagation dominating test detection flow-carried type narrowing dead code elimination language-specific techniques class hierarchy analysis devirtualization symbolic constant propagation autobox elimination escape analysis lock elision lock fusion de-reflection memory and placement transformation expression hoisting expression sinking redundant store elimination adjacent store fusion card-mark elimination merge-point splitting loop transformations loop unrolling loop peeling safepoint elimination iteration range splitting range check elimination loop vectorization global code shaping inlining (graph integration) global code motion heat-based code layout switch balancing throw inlining control flow graph transformation local code scheduling local code bundling delay slot filling graph-coloring register allocation linear scan register allocation live range splitting copy coalescing constant splitting copy removal address mode matching instruction peepholing DFA-based code generator
  7. 7. 7 vs
  8. 8. 8 CODE
  9. 9. 9 JMH = Java Microbenchmarking Harness
  10. 10. 10
  11. 11. 11 http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/ JMHSample_01_HelloWorld.java JMHSample_02_BenchmarkModes.java JMHSample_03_States.java JMHSample_04_DefaultState.java JMHSample_05_StateFixtures.java JMHSample_06_FixtureLevel.java JMHSample_07_FixtureLevelInvocation.java JMHSample_08_DeadCode.java JMHSample_09_Blackholes.java JMHSample_10_ConstantFold.java JMHSample_11_Loops.java JMHSample_12_Forking.java JMHSample_13_RunToRun.java JMHSample_15_Asymmetric.java JMHSample_16_CompilerControl.java JMHSample_17_SyncIterations.java JMHSample_18_Control.java JMHSample_20_Annotations.java JMHSample_21_ConsumeCPU.java JMHSample_22_FalseSharing.java JMHSample_23_AuxCounters.java JMHSample_24_Inheritance.java JMHSample_25_API_GA.java JMHSample_26_BatchSize.java JMHSample_27_Params.java
  12. 12. 12 HOW DOES IT WORK?
  13. 13. 13 CODE
  14. 14. 14 Intel Core i7-4500U 1.8 GHz (to 2.5 GHz with Intel Turbo Boost) 1 800 000 000 cycles per second 3 600 000 000 instructions per second (approx.) Our baseline: 2 849 277 267 empty method calls per second Not bad!
  15. 15. 15 CODE
  16. 16. 16
  17. 17. 17 @Setup / @TearDown BlackHole @Group / @GroupThreads @CompilerControl(CompilerControl.Mode.DONT_INLINE) BlackHole.consumeCPU … Other features
  18. 18. 18 CODE
  19. 19. 19
  20. 20. 20
  21. 21. 21
  22. 22. 22 EasyMock Mockito Interface mocking 167 ns/op 4080 ns/op Class mocking 8588 ns/op 4273 ns/op
  23. 23. 23 Bottomline I need to investigate a bit You need to be cautious! and be suspicious of any benchmark you read Examples: • HikariCP • NodeJS vs J2EE (http://blog.octo.com/en/the-art-of-benchmarking/)
  24. 24. 24 http://perfug.github.io / +Henri Tremblay @henri_tremblay htremblay@octo.com http://brownbaglunch.fr

×