[SOLVED] Custom benchmark/miniprofiler - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [SOLVED] Custom benchmark/miniprofiler (/showthread.php?tid=30009) |
[SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]Kenshiro[/eluser] hello i have built a custom mini/profiler for my current project (i used 3 different methods as a standalone library, as profiler extension and as a benchmark extension) I have a little problem though... if it's standalone/benchmark... the number of queries returned is always off.. it never goes over 7... The drawback of using it as a profiler extension though is that i lose the normal profiler for dev purpose (as it replace the profiler) but then the number of queries seems to be accurate... here is the method invoked : Code: function _compile_queries() { ** Update ** i tried a couple of methods... and it only returns the number of queries run in the constructor of my controller and not during a method is parsed... as i am using templates i have to append manually the footer to each submethods of my controller... which is counter efficient ... I use a main template, the methods in my controller only call the model to retrieve/parse the data and the method output the global template, this way i partially build the template from the controller (all pages besides the content have the same layout). It avoids duplication of calls to $this->parser to generate header/body/footer... But because i do so, the number of queries are off as only what's in the controller get accounted. [SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]pickupman[/eluser] What happens if you put in the controller constructor? Code: $this->output->enable_profiler(TRUE); [SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]Kenshiro[/eluser] the profiler gives the right results (this is the second picture on the right showing 9 queries (the correct number) ) there is one work around i found... but really it's not so good : using the php5 __destruct to compile the whole template and output it... problem is i have to use $this->output->get_output(); method... and if the profiler is enabled it appears twice ... There is no easy solution... if i do a custom output class maybe... to hack the profiler and allow the output to use both a miniprofiler and the normal CI one... [SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]pickupman[/eluser] The CI profiler access the DB information in system/libraries/Profiler.php at line 103. You could either duplicate this code to the format you need, or extend the Profiler class and add a method to output the number of queries as a string. [SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]Kenshiro[/eluser] This is actually what i did, same result, the problem is just that when i invoke my profiler it's always before any controller is called, thus anything after that won't work... But well i will do it with a custom MY_Output and MY_profiler [SOLVED] Custom benchmark/miniprofiler - El Forum - 04-29-2010 [eluser]Kenshiro[/eluser] OK a mod can mark this as solved, i made a custom MY_Output and MY_Profiler, anytime there is a {mini_profiler} in a view or template and that $this->output->enableminiprofiler(TRUE); is set to true.. the mini profiler will be displayed. Thanks anyway for trying to help |