Add config.measureValue callback

config.measureValue is call with the elapsed time in milliseconds for every measurement.
This is intended to be used in Chromium Performance Test.

R=tyoshino@chromium.org

Review URL: https://codereview.appspot.com/141390043

git-svn-id: https://pywebsocket.googlecode.com/svn/trunk@844 4ff78f4a-9131-11de-b045-6380ec9940d4
diff --git a/src/example/benchmark.html b/src/example/benchmark.html
index f32e532..9f0bd72 100644
--- a/src/example/benchmark.html
+++ b/src/example/benchmark.html
@@ -67,6 +67,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     sendBenchmark(config);
   }
 }
@@ -79,6 +80,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     receiveBenchmark(config);
   }
 }
@@ -91,6 +93,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     batchBenchmark(config);
   }
 }
@@ -103,6 +106,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     stop(config);
   }
 }
diff --git a/src/example/benchmark.js b/src/example/benchmark.js
index dec7b95..698e359 100644
--- a/src/example/benchmark.js
+++ b/src/example/benchmark.js
@@ -276,6 +276,7 @@
   var config = message.data.config;
   config.addToLog = workerAddToLog;
   config.addToSummary = workerAddToSummary;
+  config.measureValue = workerMeasureValue;
   if (message.data.type === 'sendBenchmark')
     sendBenchmark(config);
   else if (message.data.type === 'receiveBenchmark')
diff --git a/src/example/util.js b/src/example/util.js
index 5dd0013..a1cad49 100644
--- a/src/example/util.js
+++ b/src/example/util.js
@@ -83,6 +83,7 @@
   if (!results[size]) {
     results[size] = {n: 0, sum_t: 0, sum_t2: 0};
   }
+  config.measureValue(timePerMessageInMs);
   results[size].n ++;
   results[size].sum_t += timePerMessageInMs;
   results[size].sum_t2 += timePerMessageInMs * timePerMessageInMs;
diff --git a/src/example/util_main.js b/src/example/util_main.js
index a7b013b..b03d1c2 100644
--- a/src/example/util_main.js
+++ b/src/example/util_main.js
@@ -27,6 +27,12 @@
   summaryBox.scrollTop = 1000000;
 }
 
+// value: execution time in milliseconds.
+// config.measureValue is intended to be used in Performance Tests.
+// Do nothing here in non-PerformanceTest.
+function measureValue(value) {
+}
+
 function getIntFromInput(id) {
   return parseInt(document.getElementById(id).value);
 }
@@ -52,4 +58,6 @@
     addToLog(message.data.data);
   else if (message.data.type === 'addToSummary')
     addToSummary(message.data.data);
+  else if (message.data.type === 'measureValue')
+    measureValue(message.data.data);
 }
diff --git a/src/example/util_worker.js b/src/example/util_worker.js
index 01529d8..b64f782 100644
--- a/src/example/util_worker.js
+++ b/src/example/util_worker.js
@@ -13,3 +13,7 @@
 function workerAddToSummary(text) {
   postMessage({type: 'addToSummary', data: text});
 }
+
+function workerMeasureValue(value) {
+  postMessage({type: 'measureValue', data: value});
+}
diff --git a/src/example/xhr_benchmark.html b/src/example/xhr_benchmark.html
index 5919d2e..eeb00f1 100644
--- a/src/example/xhr_benchmark.html
+++ b/src/example/xhr_benchmark.html
@@ -69,6 +69,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     sendBenchmark(config);
   }
 }
@@ -82,6 +83,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     receiveBenchmark(config);
   }
 }
@@ -94,6 +96,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     batchBenchmark(config);
   }
 }
@@ -106,6 +109,7 @@
   } else {
     config.addToLog = addToLog;
     config.addToSummary = addToSummary;
+    config.measureValue = measureValue;
     stop(config);
   }
 }
diff --git a/src/example/xhr_benchmark.js b/src/example/xhr_benchmark.js
index 16fcc26..eaa75ce 100644
--- a/src/example/xhr_benchmark.js
+++ b/src/example/xhr_benchmark.js
@@ -346,6 +346,7 @@
   var config = message.data.config;
   config.addToLog = workerAddToLog;
   config.addToSummary = workerAddToSummary;
+  config.measureValue = workerMeasureValue;
   if (message.data.type === 'sendBenchmark')
     sendBenchmark(config);
   else if (message.data.type === 'receiveBenchmark')