Testing code to get the average time for the calls
<p>This is my code, I am trying to test what's the average time to make a call to getLocationByIp method by passing ipAddress in that. So what I did is that, I am generating some random ipAddress and passing that to getLocationByIp and then calculating the time difference. And then putting that to HashMap with there counts. And after wards I am priniting the hash map to see
what's the actual count. So this is the right way to test this? or there is some other way. Becuase in my case I am not sure whether my generateIPAddress method generates random ipAddress everytime. I am also having start_total time before entering the loop and then end_total time after everything gets completed. So on that I can calculate the average time?</p>

<pre><code>    long total = 10000;
    long found = 0;
    long found_country = 0;
    long runs = total;
    Map&lt;Long, Long&gt; histgram = new HashMap&lt;Long, Long&gt;();
    try {
        long start_total = System.nanoTime();
        while(runs &gt; 0) {

            String ipAddress = generateIPAddress();

            long start_time = System.nanoTime();

            resp = PersonalizationGeoLocationServiceClientHelper.getLocationByIp(ipAddress);

            long end_time = System.nanoTime();

            long difference = (end_time - start_time)/1000000;      

            Long count = histgram.get(difference);
            if (count != null) {
                count++;
                histgram.put(Long.valueOf(difference), count);
            } else {
                histgram.put(Long.valueOf(difference), Long.valueOf(1L));
            }

            runs--;

        }
        long end_total = System.nanoTime();

        long finalTotal = (end_total - start_total)/1000000;

        float avg = (float)(finalTotal) / total;



        Set&lt;Long&gt; keys = histgram.keySet();

        for (Long key : keys) {
            Long value = histgram.get(key);
            System.out.println("$$$GEO OPTIMIZE SVC MEASUREMENT$$$, HG data, " + key + ":" + value);
        }
</code></pre>

<p>This is my generateIpAddress method-</p>

<pre><code>private String generateIPAddress() {

        Random r = new Random();

        String s = r.nextInt(256) + "." + r.nextInt(256) + "." + r.nextInt(256) + "." + r.nextInt(256);

        return s;

    }
</code></pre>

<p>Any suggestions will be appreciated.</p>
