In an earlier post I detailed how I was capturing the time spent parsing a page. The code looks like this:
$page_parse_start_microtime = microtime();
$page_parse_time = microtime_duration($page_parse_start_microtime, microtime());
The call to the pparse(’body’) function appears at or near the bottom in essentially every content page in phpBB2. By including this code I capture the start time just before the function call, and get the completion time after the function returns. One astute reader pointed out to me that this ignores the parsing time spent in rendering the page header and the page footer, and they were right. But I don’t think it matters. Besides, I don’t want to alter my testing process now as I would have to go back and start all over again, and I don’t want to do that.
Why doesn’t it matter?
In addition to capturing the body parse time I am also capturing the page SQL time (as detailed here) and the total page time from top to bottom. That last metric is the important one, because it does include the parse time for the header and footer and anything in between as well.
When I started this process I moved my timer code around and checked all sorts of things. When I checked the times for parsing the header and footer they were inconsequential compared to the time it took to parse the body template. Given that result I stopped looking at the header and footer times. And it was for that reason that I did not capture those times seperately during my benchmark process that is still ongoing.
What do I collect? I capture the total page time, the total SQL time, and the body parse time.
Total SQL Time per Page
I capture the total SQL time is so I can make sure that the average time spent talking to the database is the same for all template engines. My final analysis will include that adjustment.
Body Parse Time
This appears to be where the bulk of the page generation time occurs. During my initial testing I found that anywhere from 70 to 95% of the total page generation time was during this one function call, so it seemed clear to me that this is where I needed to focus my attention.
Total Page Time
As mentioned above, I don’t think that the header and footer parsing time is a substantial part of the page parsing. But by using the total page time as a starting point I can interpolate some numbers. First, I can deduct the SQL time from the page time. That gives me a number for the page generation time without the database overhead. Then I can deduct the body parse time (captured as a specific metric). Whatever time is left is, well, everything else. That includes the parsing of the header and the footer, but also the php code execution time. For example, on viewtopic.php there is a lot to do. So I might expect that the page time would be higher there than on other pages because of all of the processing (signatures, bbcode in posts, smilies) that goes on.
The bottom line is that I don’t think it matters that I am not capturing the “total” page parsing time. Or rather, I will claim that I am capturing the total page parsing time and that the header and footer are not really part of the page anyway. I will make this clear when I publish my final results.