Advertisement
Guest User

Untitled

a guest
May 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. List<CIBSubjectData> list1 = .....
  2.  
  3. list1.forEach(data ->
  4. merge(data)
  5. );
  6.  
  7. for (CIBSubjectData data : list1) {
  8. merge(data);
  9. }
  10.  
  11. public class Warmup {
  12. static int dummy;
  13.  
  14. static void merge(String s) {
  15. dummy += s.length();
  16. dummy++;
  17. dummy -= s.length();
  18. }
  19.  
  20. public static void main(String[] args) throws IOException {
  21. List<String> list1 = new ArrayList<>();
  22. Random rand = new Random(1);
  23.  
  24. for (int i = 0; i < 100_000; i++) {
  25. list1.add(Long.toString(rand.nextLong()));
  26. }
  27.  
  28. // this will boostrap the bytecode instrumentation
  29. // Stream.of("foo".toCharArray()).forEach(System.out::println);
  30. long start = System.nanoTime();
  31. list1.forEach(data -> merge(data));
  32.  
  33. long end = System.nanoTime();
  34. System.out.printf("duration: %d%n", end - start);
  35. System.out.println(dummy);
  36. }
  37. }
  38.  
  39. duration: 71694425
  40.  
  41. duration: 7516086
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement