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

Side by Side Diff: native_client_sdk/src/examples/benchmarks/example.js

Issue 664543003: Benchmark sample for SDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function moduleDidLoad() {
6 }
7
8
9 // Add event listeners after the NaCl module has loaded. These listeners will
10 // forward messages to the NaCl module via postMessage()
11 function attachListeners() {
12 setTimeout(function() { common.updateStatus('READY TO RUN'); }, 200);
13 document.getElementById('benchmark').addEventListener('click',
14 function() {
15 common.naclModule.postMessage({'message' : 'run_benchmark'});
16 common.updateStatus('BENCHMARKING... (please wait)');
17 var window = document.getElementById('result').contentWindow;
18 window.document.writeln('<samp>Starting Benchmark Suite<br>');
19 window.document.writeln('<table>');
20 });
21 }
22
23
24 // Handle a message coming from the NaCl module.
25 function handleMessage(message_event) {
26 if (message_event.data.message == 'benchmark_result') {
27 // benchmark result
28 var name = message_event.data.benchmark.name;
29 var result = message_event.data.benchmark.result;
30 var text = '<tr><th>' + name + ': </th><th>' + result + '</th></tr>';
31 console.log(text);
32 var window = document.getElementById('result').contentWindow;
33 window.document.writeln(text);
34 }
35 if (message_event.data.message == 'benchmark_finish') {
36 common.updateStatus('READY TO RUN');
37 var window = document.getElementById('result').contentWindow;
38 window.document.writeln('</table>');
39 window.document.writeln('Finished.<br><br></samp>');
40 }
41 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698