Stats Module
Overview
The Stats module allows you to run multiple benchmarks and view averaged results in table format.
# | Benchmark | Info | Time | Memory | Count | |
---|---|---|---|---|---|---|
1 | Load RSS | 0.5286 | 0.00MB | 10 | ||
2 | Instantiate Nav | 0.0072 | 0.18MB | 10 | ||
3 | Generate item config | Parsed 40 nodes | 0.0071 | 0.03MB | 10 | |
4 | Generate menus | Generated 24 parent items and 40 child items | 0.0050 | 0.02MB | 10 |
Stats is essentially a more effective and user-friendly Profiler, with the following features:
- Averages benchmark results over a series of runs / requests
- Allows you to log arbitrary information with each benchmark
- Displays minimum, maximum and most-recent results in tooltips
- Allows multiple sets of benchmarks to be run in "groups"
Furthermore, the user interface offers sortable columns and easy delation of results (interact with the table above to see).
Quick start
Simple code example
The following example demonstrates a typical usage scenario; running a couple of benchmarks consecutively, and displaying results:
// Create the stats instance $stats = Stats::instance(); // benchmark 1 $stats->start('Decombomulate'); decombobulate(TRUE); $stats->stop(); // benchmark 2 $stats->start('Recombomulate'); recombobulate(TRUE); $stats->stop('Deleted and created ' . $num_widgits . ' widgets'); // show results $stats->show();
API guide
Demos
(These demos can also be run locally by navigating to /stats/demos/ in your Kohana installation)