0

I am trying to get the total load time for each page by parsing a HAR file. I found a code segment where the total time is found by subtracting the time of the last get from the start of the page. So far so good.

I have an outer loop that goes through all the pages.

      List<HarPage> pages = log.getPages().getPages();
        for (HarPage page : pages)
        {
        / confirms that I go through all the pages
        writer.println("\n\n***\n    Top of page loop, Page Number   :" + pageNumber);
        }



/* The problem is that I would like to process all the entries for one page  at a time.  This inner loop is not working properly and seems to go through  the entries for all the pages.  The calling sequence is as follows:
*/    
    List<HarPage> pages = log.getPages().getPages();
    for (HarPage page : pages)
    {
                        HarEntries entries = log.getEntries();
                        List<HarEntry> entryList = entries.getEntries();
                        int entryIndex = 0;
                        for (HarEntry entry : entryList) {
                        / print entry number to see how many entries it processes
                        writer.println("Page Number: " + pageNumber + "  Entry: " + entryIndex++);
                        entryIndex++;
                        }
    }

I have 124 entries in the first page (which I confirmed by processing the file through http://www.softwareishard.com/har/viewer/ but my program will go through 1305 entries for all pages.

Thanks, Tariq Badsha

PS I found out that there is a field in the Entry entry.getPageRef(). This changes when I go to the next page. So maybe this can be used as a trigger to exit from the inner loop. If someone has a more elegant solution Please comment TB

Tariq
  • 1
  • 2
  • Add language tag, please, it can help to attract more users to this question. – Andrew Jun 10 '16 at 04:48
  • What HAR API are you using? I don't recognise a `log.getPages().getPages()` API for instance. – Paul Grime Jul 28 '16 at 15:05
  • Hi Andrew, Paul, thanks for responding. I was not using an API but some library functions. In any event, I had the work around I described above and it worked. The program is now end of life. – Tariq Jul 28 '18 at 15:49

0 Answers0