Browse files

Statistics display functionality moved out to a separate file

  • Loading branch information...
1 parent 07d59ae commit ab332c9e6a207d86ffd3e665f65a9a598362b6ee @penartur committed May 5, 2012
Showing with 65 additions and 61 deletions.
  1. +2 −61 lib/benchmark.js
  2. +63 −0 lib/statistics-display.js
View
63 lib/benchmark.js
@@ -5,6 +5,7 @@ var WorkingQueue = require('capisce').WorkingQueue;
var BenchmarkContext = require('./benchmark-context');
var dateTimer = require('./timers/datetimer');
+var statisticsDisplay = require('./statistics-display');
var TIMERTYPES = {
DATETIMER: 'datetimer'
@@ -92,66 +93,6 @@ Benchmark.prototype.runMultiple = function (simultaneousRequestsList, callback,
queue.go();
}
-Benchmark.prototype.showStats = function (simultaneousRequests, stats) {
- var Table = require('cli-table');
- console.log("Statistics for " + simultaneousRequests + " simultaneous requests");
- for (var engineName in stats.totals) {
- console.log("Processing " + engineName + " took " + stats.totals[engineName].time + " (" + (stats.totals[engineName].time / stats.totals[engineName].tasks) + " per request)");
- }
- for (var pageName in stats.perPage) {
- console.log(pageName);
- var table = new Table({
- head: [
- 'Engine',
- 'Trimmed mean',
- 'Median',
- 'Temporal disrepancy',
- 'Mean',
- 'Top 10%',
- 'Bottom 10%',
- 'Max',
- 'Sample size'
- ],
- colWidths: [
- 15,
- 14,
- 8,
- 21,
- 8,
- 9,
- 12,
- 8,
- 13
- ],
- colAligns: [
- 'left',
- 'right',
- 'right',
- 'right',
- 'right',
- 'right',
- 'right',
- 'right',
- 'right'
- ]
- });
- for (var engineName in stats.perPage[pageName]) {
- var entry = stats.perPage[pageName][engineName];
- table.push([
- engineName,
- entry.trimmedMean,
- entry.median,
- entry.temporalDisrepancy,
- entry.mean,
- entry.top10,
- entry.bottom10,
- entry.max,
- entry.num
- ]);
- }
- console.log(table.toString());
- console.log();
- }
-}
+Benchmark.statisticsDisplay = statisticsDisplay;
module.exports = Benchmark;
View
63 lib/statistics-display.js
@@ -0,0 +1,63 @@
+"use strict";
+
+exports.showCliTable = function (simultaneousRequests, stats) {
+ var Table = require('cli-table');
+ console.log("Statistics for " + simultaneousRequests + " simultaneous requests");
+ for (var engineName in stats.totals) {
+ console.log("Processing " + engineName + " took " + stats.totals[engineName].time + " (" + (stats.totals[engineName].time / stats.totals[engineName].tasks) + " per request)");
+ }
+ for (var pageName in stats.perPage) {
+ console.log(pageName);
+ var table = new Table({
+ head: [
+ 'Engine',
+ 'Trimmed mean',
+ 'Median',
+ 'Temporal disrepancy',
+ 'Mean',
+ 'Top 10%',
+ 'Bottom 10%',
+ 'Max',
+ 'Sample size'
+ ],
+ colWidths: [
+ 15,
+ 14,
+ 8,
+ 21,
+ 8,
+ 9,
+ 12,
+ 8,
+ 13
+ ],
+ colAligns: [
+ 'left',
+ 'right',
+ 'right',
+ 'right',
+ 'right',
+ 'right',
+ 'right',
+ 'right',
+ 'right'
+ ]
+ });
+ for (var engineName in stats.perPage[pageName]) {
+ var entry = stats.perPage[pageName][engineName];
+ table.push([
+ engineName,
+ entry.trimmedMean,
+ entry.median,
+ entry.temporalDisrepancy,
+ entry.mean,
+ entry.top10,
+ entry.bottom10,
+ entry.max,
+ entry.num
+ ]);
+ }
+ console.log(table.toString());
+ console.log();
+ }
+}

0 comments on commit ab332c9

Please sign in to comment.