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