OLD | NEW |
(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 } |
OLD | NEW |