storing profiler data - specifically elapsed time - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: storing profiler data - specifically elapsed time (/showthread.php?tid=49571) |
storing profiler data - specifically elapsed time - El Forum - 02-25-2012 [eluser]skattabrain[/eluser] I'm trying to store the memory peak usage and the total script execution time using a post_system hook. On each page load, I set a "page id" config variable... Code: $config['page_id'] = md5(uniqid(mt_rand())); Then I do a post_controller_constructor hook to log the page view, then at the very end I want to set a post_system update to the tracking record for this page... Code: function update_trackme_times() Now it records the peak memory usage really well, but I can't seem to make use of the benchmarking class to get the equivalent of {elapsed time} Any ideas? storing profiler data - specifically elapsed time - El Forum - 02-25-2012 [eluser]CroNiX[/eluser] Take a look at /system/CodeIgniter.php. It benchmarks that stuff for every request (which is where it gets {elapsed_time} and other from). You just need to access it in the benchmark object. You can access by globalizing $BM and accessing it in your post hook. storing profiler data - specifically elapsed time - El Forum - 02-25-2012 [eluser]skattabrain[/eluser] super, that works... I actually saw a post you made earlier that was similar but I usually avoid globals, figuring there was a more "codeigniter way" Thanks though! What are your thoughts on this... Code: function update_trackme_times() I think I'll add conditional code to just return out if these times are under a certain target... hmmm Thanks again storing profiler data - specifically elapsed time - El Forum - 02-25-2012 [eluser]CroNiX[/eluser] You could use the benchmark class instance itself to do the time calculations. Code: function update_trackme_times() storing profiler data - specifically elapsed time - El Forum - 02-25-2012 [eluser]skattabrain[/eluser] [quote author="CroNiX" date="1330197750"]You could use the benchmark class instance itself to do the time calculations. Code: function update_trackme_times() Thanks, that's exactly what I was looking for. |