Guest User

Untitled

a guest
Feb 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package ttldtor;
  2.  
  3. import org.openjdk.jmh.annotations.Benchmark;
  4. import org.openjdk.jmh.annotations.BenchmarkMode;
  5. import org.openjdk.jmh.annotations.Fork;
  6. import org.openjdk.jmh.annotations.Measurement;
  7. import org.openjdk.jmh.annotations.Mode;
  8. import org.openjdk.jmh.annotations.Warmup;
  9.  
  10. import java.util.concurrent.TimeUnit;
  11.  
  12. /**
  13. * @author kalin
  14. * @since 09.02.2018
  15. */
  16. public class Runner {
  17. @Benchmark
  18. @Fork(value = 1, warmups = 2)
  19. @Measurement(iterations = 1)
  20. @BenchmarkMode(Mode.Throughput)
  21. @Warmup(iterations = 1, timeUnit = TimeUnit.MILLISECONDS)
  22. public void boxed() {
  23. Long sum = 0L;
  24.  
  25. for (long i = 0; i < Integer.MAX_VALUE; i++) {
  26. sum += i;
  27. }
  28. }
  29.  
  30.  
  31. @Benchmark
  32. @Fork(value = 1, warmups = 2)
  33. @Measurement(iterations = 1)
  34. @BenchmarkMode(Mode.Throughput)
  35. @Warmup(iterations = 1, timeUnit = TimeUnit.MILLISECONDS)
  36. public void notBoxed() {
  37. long sum = 0L;
  38.  
  39. for (long i = 0; i < Integer.MAX_VALUE; i++) {
  40. sum += i;
  41. }
  42. }
  43.  
  44. public static void main(String[] args) throws Exception {
  45. org.openjdk.jmh.Main.main(args);
  46. }
  47. }
  48.  
  49.  
  50. /*
  51.  
  52.  
  53. # Run complete. Total time: 00:00:52
  54.  
  55. Benchmark Mode Cnt Score Error Units
  56. Runner.boxed thrpt 0,152 ops/s
  57. Runner.notBoxed thrpt 1,659 ops/s
  58.  
  59. Process finished with exit code 0
  60.  
  61. */
Add Comment
Please, Sign In to add comment