/** * Count all the things we want to count by grouping on key values. * * We may need to convert the actual value into a subset. * For the grouping fields see class-vt-row.php * * * Key | Subset | What this shows * ---------- | ------- | --------------------------------------- * plugins | null | Group by number of active plugins = 41 * files | | ranges from 446 to 556 * queries | | ranges from 16 to 1081 - with some large gaps * elapsed | elapsed | * */ function count_things() { $grouper = new Object_Grouper(); echo "Grouping: " . count($this->rows) . PHP_EOL; $grouper->populate($this->rows); $grouper->subset(null); $grouper->groupby("suri"); $grouper->arsort(); $this->having = 100; $grouper->having(array($this, "having_filter_value_ge")); $grouper->report_groups(); // The 'tl' part of suritl stands for top level not term last! $grouper->time_field("final"); $grouper->subset(null); $grouper->groupby("suritl"); // we can't sort and expect the elapsed total to be sorted too // so in the mean time don't sort here // $grouper->arsort(); //$grouper->report_percentages(); // Also there's a bug in report_percentages when mixed with time_field // it calculates the average from the percentage figure not the count. $grouper->having(array($this, "having_filter_value_ge")); $this->having = count($this->rows) / 100; $grouper->report_groups(); $this->having = 0.05; $grouper->report_percentages(); /** $grouper->subset(); $grouper->groupby( "files" ); $grouper->ksort(); $grouper->report_groups(); $grouper->subset(); $grouper->groupby( "queries" ); $grouper->ksort(); $grouper->report_groups(); $grouper->subset(); $grouper->groupby( "remote_IP" ); $grouper->ksort(); $grouper->report_groups(); */ $grouper->having(); $grouper->time_field(); $grouper->groupby("elapsed", array($this, "elapsed")); $grouper->ksort(); $grouper->report_groups(); $grouper->time_field(); $grouper->groupby("final", array($this, "elapsed")); $grouper->ksort(); $grouper->report_percentages(); $merger = new CSV_merger(); $merger->append($grouper->groups); $merger->append($grouper->percentages); echo "Merged report:" . PHP_EOL; $merger->report(); /** * Produce a chart comparing the execution times for each month. * with the total count converted to percentages to enable easier visual comparison * */ $grouper->where(array($this, "month_filter")); $merger = new CSV_merger(); for ($this->month = 10; $this->month <= 12; $this->month++) { $grouper->groupby("final", array($this, "elapsed")); $grouper->percentages(); $merger->append($grouper->percentages); } $merger->report(); }
/** * Count by grouping on the suritl * */ function count_things_differently() { $grouper = new Object_Grouper(); echo "Grouping: " . count($this->rows) . PHP_EOL; $grouper->populate($this->rows); $grouper->time_field("final"); $grouper->where(array($this, "lt6secs")); $grouper->groupby("surisl", array($this, "surisl")); $this->having = 6.0; $grouper->having(array($this, "having_filter_value_le")); //$grouper->percentages(); //$grouper->averages(); return $grouper; }