0

i have two methods and i want to compute running time for each, but when debugging the code it result values different from result when execute code.i want to know what is the problem.

    startTime1 = System.currentTimeMillis();
          BloomFilterIndex rr=  re.encryptTree(st);
          endEncryptedTreeTime= System.currentTimeMillis() - startTime1;

          endEncryptedTreeTime/=1000.0;
          endEncryptedTreeTime1=(endEncryptedTreeTime)-(re.endCreateMatrix);

  startTime11 = System.currentTimeMillis();
                 re.encryptFiles(re.bfList);
              encryptedBFListInTime= System.currentTimeMillis()-startTime11;

              encryptedBFListInTime/=1000.0;
               encryptedBFListInTime1=(endBloomFilterListTime)+(encryptedBFListInTime)

when debugging it result that endEncryptedTreeTime1greater than encryptedBFListInTime1but when execute program result the inverse.

  • Java microbenchmarks are really hard because the JIT compiler and GC can make the results unpredictable. It is strongly recommended to use [`jmh`](http://openjdk.java.net/projects/code-tools/jmh/), the Java Microbenchmark Harness, for benchmarking Java code. – David Conrad May 17 '18 at 01:41
  • See: [How do I write a correct micro benchmark in Java?](https://stackoverflow.com/questions/504103/how-do-i-write-a-correct-micro-benchmark-in-java) – David Conrad May 17 '18 at 01:43

0 Answers0