fork download
  1. class Point2D
  2. {
  3. public int x,y;
  4. }
  5.  
  6. public class Main
  7. {
  8. public static void main(String[] args)
  9. {
  10. {
  11. long start = System.nanoTime();
  12. int[] v = new int[1 << 24];
  13. long end = System.nanoTime();
  14. System.out.println(v[200]+" plain_array elapsed = "+(end - start)*1.0e-9);
  15. }
  16. {
  17. long start = System.nanoTime();
  18. Point2D[] v = new Point2D[1 << 23];
  19. for(int i = 0; i != v.length; ++i)
  20. v[i] = new Point2D();
  21. long end = System.nanoTime();
  22. System.out.println(v[100].x+" structured_array elapsed = "+(end - start)*1.0e-9);
  23. }
  24. }
  25. }
  26.  
Success #stdin #stdout 1.29s 380352KB
stdin
Standard input is empty
stdout
0 plain_array elapsed = 0.069230892
0 structured_array elapsed = 1.1570459050000002