Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: chrome/common/extensions/docs/examples/api/messaging/timer/popup.html

Issue 3126029: Move the chromium.Interval to chrome.Interval as part of the benchmarking... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: One more missing file!! Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/renderer/render_thread.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/examples/api/messaging/timer/popup.html
===================================================================
--- chrome/common/extensions/docs/examples/api/messaging/timer/popup.html (revision 57339)
+++ chrome/common/extensions/docs/examples/api/messaging/timer/popup.html (working copy)
@@ -1,71 +1,77 @@
-<head>
-<style>
-tr {
- white-space: nowrap;
-}
-.results {
- text-align: right;
- min-width: 6em;
- color: black;
-}
-</style>
-<script>
-function setChildTextNode(elementId, text) {
- document.getElementById(elementId).innerText = text;
-}
-
-// Tests the roundtrip time of sendRequest().
-function testRequest() {
- setChildTextNode("resultsRequest", "running...");
-
- chrome.tabs.getSelected(null, function(tab) {
- var timer = new chromium.Interval();
- timer.start();
-
- chrome.tabs.sendRequest(tab.id, {counter: 1}, function handler(response) {
- if (response.counter < 1000) {
- chrome.tabs.sendRequest(tab.id, {counter: response.counter}, handler);
- } else {
- timer.stop();
- var usec = Math.round(timer.microseconds() / response.counter);
- setChildTextNode("resultsRequest", usec + "usec");
- }
- });
- });
-}
-
-// Tests the roundtrip time of Port.postMessage() after opening a channel.
-function testConnect() {
- setChildTextNode("resultsConnect", "running...");
-
- chrome.tabs.getSelected(null, function(tab) {
- var timer = new chromium.Interval();
- timer.start();
-
- var port = chrome.tabs.connect(tab.id);
- port.postMessage({counter: 1});
- port.onMessage.addListener(function getResp(response) {
- if (response.counter < 1000) {
- port.postMessage({counter: response.counter});
- } else {
- timer.stop();
- var usec = Math.round(timer.microseconds() / response.counter);
- setChildTextNode("resultsConnect", usec + "usec");
- }
- });
- });
-}
-</script>
-</head>
-<body>
-<table>
- <tr>
- <td><button onclick="testRequest()">Measure sendRequest</button></td>
- <td id="resultsRequest" class="results">(results)</td>
- </tr>
- <tr>
- <td><button onclick="testConnect()">Measure postMessage</button></td>
- <td id="resultsConnect" class="results">(results)</td>
- </tr>
-</table>
-</body>
+<head>
+<style>
+tr {
+ white-space: nowrap;
+}
+.results {
+ text-align: right;
+ min-width: 6em;
+ color: black;
+}
+</style>
+<script>
+if (!chrome.benchmarking) {
+ alert("Warning: Looks like you forgot to run chrome with " +
+ " --enable-benchmarking set.");
+ return;
+}
+
+function setChildTextNode(elementId, text) {
+ document.getElementById(elementId).innerText = text;
+}
+
+// Tests the roundtrip time of sendRequest().
+function testRequest() {
+ setChildTextNode("resultsRequest", "running...");
+
+ chrome.tabs.getSelected(null, function(tab) {
+ var timer = new chrome.Interval();
+ timer.start();
+
+ chrome.tabs.sendRequest(tab.id, {counter: 1}, function handler(response) {
+ if (response.counter < 1000) {
+ chrome.tabs.sendRequest(tab.id, {counter: response.counter}, handler);
+ } else {
+ timer.stop();
+ var usec = Math.round(timer.microseconds() / response.counter);
+ setChildTextNode("resultsRequest", usec + "usec");
+ }
+ });
+ });
+}
+
+// Tests the roundtrip time of Port.postMessage() after opening a channel.
+function testConnect() {
+ setChildTextNode("resultsConnect", "running...");
+
+ chrome.tabs.getSelected(null, function(tab) {
+ var timer = new chrome.Interval();
+ timer.start();
+
+ var port = chrome.tabs.connect(tab.id);
+ port.postMessage({counter: 1});
+ port.onMessage.addListener(function getResp(response) {
+ if (response.counter < 1000) {
+ port.postMessage({counter: response.counter});
+ } else {
+ timer.stop();
+ var usec = Math.round(timer.microseconds() / response.counter);
+ setChildTextNode("resultsConnect", usec + "usec");
+ }
+ });
+ });
+}
+</script>
+</head>
+<body>
+<table>
+ <tr>
+ <td><button onclick="testRequest()">Measure sendRequest</button></td>
+ <td id="resultsRequest" class="results">(results)</td>
+ </tr>
+ <tr>
+ <td><button onclick="testConnect()">Measure postMessage</button></td>
+ <td id="resultsConnect" class="results">(results)</td>
+ </tr>
+</table>
+</body>
« no previous file with comments | « no previous file | chrome/renderer/render_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698