You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BenchProceedNew.java 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package test1;
  2. class BenchProceedNew2 {
  3. }
  4. class BenchProceedNew3 {
  5. int p, q;
  6. BenchProceedNew3(int i, int j) {
  7. p = i; q = j;
  8. }
  9. }
  10. public class BenchProceedNew {
  11. public static final int N = 10000000;
  12. Object result0;
  13. public int org0() {
  14. long time = System.currentTimeMillis();
  15. Object obj = null;
  16. for (int i = N; i > 0; --i)
  17. obj = new BenchProceedNew2();
  18. long time2 = System.currentTimeMillis();
  19. result0 = obj;
  20. return (int)(time2 - time);
  21. }
  22. public int jvst0() {
  23. long time = System.currentTimeMillis();
  24. Object obj = null;
  25. for (int i = N; i > 0; --i)
  26. obj = new BenchProceedNew2();
  27. long time2 = System.currentTimeMillis();
  28. result0 = obj;
  29. return (int)(time2 - time);
  30. }
  31. public int org2() {
  32. long time = System.currentTimeMillis();
  33. Object obj = null;
  34. for (int i = N; i > 0; --i)
  35. obj = new BenchProceedNew3(i, i);
  36. long time2 = System.currentTimeMillis();
  37. result0 = obj;
  38. return (int)(time2 - time);
  39. }
  40. public int jvst2() {
  41. long time = System.currentTimeMillis();
  42. Object obj = null;
  43. for (int i = N; i > 0; --i)
  44. obj = new BenchProceedNew3(i, i);
  45. long time2 = System.currentTimeMillis();
  46. result0 = obj;
  47. return (int)(time2 - time);
  48. }
  49. public static void main(String[] args) throws Exception {
  50. BenchProceedNew bp = new BenchProceedNew();
  51. System.out.println("iteration " + N);
  52. System.out.println("org0 (msec) " + bp.org0());
  53. System.out.println("jvst0 (msec) " + bp.jvst0());
  54. System.out.println("org2 (msec) " + bp.org2());
  55. System.out.println("jvst2 (msec) " + bp.jvst2());
  56. System.out.println("org0 (msec) " + bp.org0());
  57. System.out.println("jvst0 (msec) " + bp.jvst0());
  58. System.out.println("org2 (msec) " + bp.org2());
  59. System.out.println("jvst2 (msec) " + bp.jvst2());
  60. }
  61. }