fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.function.Consumer;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main(String[] args) {
  12. long now;
  13.  
  14. now = System.currentTimeMillis();
  15. foo(new Consumer<String>(){
  16. @Override
  17. public void accept(String text) {
  18. }});
  19. System.err.println("Elapsed: "+(System.currentTimeMillis()-now)+"ms");
  20.  
  21.  
  22. now = System.currentTimeMillis();
  23. foo(text -> {});
  24. System.err.println("Elapsed: "+(System.currentTimeMillis()-now)+"ms");
  25.  
  26. }
  27.  
  28. static void foo(Consumer<String> consumer) {
  29. for (int i=0; i<10; i++) {
  30. try {
  31. Thread.sleep(5);
  32. } catch (InterruptedException ignore) {
  33. // sorry this is a test
  34. }
  35.  
  36. consumer.accept("");
  37. }
  38. }
  39. }
Success #stdin #stdout #stderr 0.1s 35936KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Elapsed: 51ms
Elapsed: 55ms