0

I'm trying to store the time in milliseconds for every time this time park is executed. And then I would like to use HdrHistogram to represent the latency.

However, i can't store the times in my array. Please, could you provide any help?

public class PracticeLatency1
{
 public static void main(String [] args)
{
int[] startTimes;
long startTime;
int index=0;

 startTimes = new int[10000];
 startTime = System.currentTimeMillis();
 runCalculations();
 startTimes[index++] = (int) (System.currentTimeMillis() - startTime);
 System.out.println(startTimes);
}
   /**
    * Run the practice calculations
    */
   // System.currentTimeMillis()
    private static void runCalculations()
    {
    // Create a random park time simulator
    BaseSyncOpSimulator syncOpSimulator = new SyncOpSimulRndPark(TimeUnit.NANOSECONDS.toNanos(100), 
    TimeUnit.MICROSECONDS.toNanos(100));

    // Execute the operation lot of times
    for(int i = 0; i < 10000; i++)
    {
        syncOpSimulator.executeOp();
        
    }  
     
    // TODO Show the percentile distribution of the latency calculation of each executeOp call

    }
     }
  • 1
    You set your `startTimes` array to `null`. How do you expect you would be able to add any values? Do you know, how many values you want to add? Then you have to initialize your array with `startTimes = new int[1000]` (or whatever size you need) – derpirscher Oct 18 '20 at 11:38
  • Your `startTimes` is not initialized and you shoud have a loop to set the `startTimes`. – haoyu wang Oct 18 '20 at 11:41
  • thank you for your answers!!. I think that i now have initialized startTimes to 10.000 which is the number of times the park time function is going to be executed. But, how do i add the loop if there is already a loop in the park time function? – Learning_leo Oct 18 '20 at 12:26
  • thank you @haoyuwang, how can i add the loop? because now my array looks like: [522,0,0,0,0...] – Learning_leo Oct 18 '20 at 12:46

0 Answers0