| OLD | NEW |
| 1 function perfTestAddToLog(text) { | |
| 2 PerfTestRunner.log(text); | |
| 3 } | |
| 4 | |
| 5 function perfTestAddToSummary(text) { | |
| 6 } | |
| 7 | |
| 8 function perfTestMeasureValue(value) { | |
| 9 PerfTestRunner.measureValueAsync(value); | |
| 10 PerfTestRunner.gc(); | |
| 11 } | |
| 12 | |
| 13 function perfTestNotifyAbort() { | |
| 14 PerfTestRunner.logFatalError("benchmark aborted"); | |
| 15 } | |
| 16 | |
| 17 const numIterations = 10; | 1 const numIterations = 10; |
| 18 const numWarmUpIterations = 5; | 2 const numWarmUpIterations = 5; |
| 19 | 3 |
| 20 function getConfigForPerformanceTest(connectionType, dataType, async, | 4 function startPerformanceTest(connectionType, benchmarkName, |
| 21 verifyData) { | 5 dataType, isWorker, async, verifyData){ |
| 22 return { | 6 var iframe = document.createElement('iframe'); |
| 23 prefixUrl: | 7 if (connectionType === 'WebSocket') { |
| 24 connectionType === 'WebSocket' ? 'ws://localhost:8001/benchmark_helper' : | 8 iframe.src = "http://localhost:8001/performance_test_iframe.html"; |
| 25 'http://localhost:8001/073be001e10950692ccbf3a2ad21c245', // XHR or fetch | 9 } else if (connectionType === 'XHR') { |
| 26 printSize: true, | 10 iframe.src = "http://localhost:8001/xhr_performance_test_iframe.html"; |
| 27 numXHRs: 1, | 11 } else { |
| 28 numFetches: 1, | 12 iframe.src = "http://localhost:8001/fetch_performance_test_iframe.html"; |
| 29 numSockets: 1, | 13 } |
| 30 // + 1 is for a warmup iteration by the Telemetry framework. | 14 iframe.onload = function() { |
| 31 numIterations: numIterations + numWarmUpIterations + 1, | 15 var child = iframe.contentWindow; |
| 32 numWarmUpIterations: numWarmUpIterations, | 16 PerfTestRunner.prepareToMeasureValuesAsync({ |
| 33 minTotal: 10240000, | 17 done: function() { |
| 34 startSize: 10240000, | 18 child.postMessage({'command': 'stop'}, |
| 35 stopThreshold: 10240000, | 19 'http://localhost:8001'); |
| 36 multipliers: [2], | 20 }, |
| 37 verifyData: verifyData, | 21 unit: 'ms', |
| 38 dataType: dataType, | 22 dromaeoIterationCount: numIterations |
| 39 async: async, | 23 }); |
| 40 addToLog: perfTestAddToLog, | 24 |
| 41 addToSummary: perfTestAddToSummary, | 25 child.postMessage({'command': 'start', |
| 42 measureValue: perfTestMeasureValue, | 26 'connectionType': connectionType, |
| 43 notifyAbort: perfTestNotifyAbort | 27 'benchmarkName': benchmarkName, |
| 28 'dataType': dataType, |
| 29 'isWorker': isWorker, |
| 30 'async': async, |
| 31 'verifyData': verifyData, |
| 32 'numIterations': numIterations, |
| 33 'numWarmUpIterations': numWarmUpIterations}, |
| 34 'http://localhost:8001'); |
| 44 }; | 35 }; |
| 36 document.body.appendChild(iframe); |
| 45 } | 37 } |
| 46 | 38 |
| 47 function startPerformanceTest(connectionType, benchmarkName, | 39 onmessage = function(message) { |
| 48 dataType, isWorker, async, verifyData){ | 40 if (message.data.command === 'log') { |
| 49 initWorker(connectionType, 'http://localhost:8001'); | 41 PerfTestRunner.log(message.data.value); |
| 50 | 42 } else if (message.data.command === 'measureValue') { |
| 51 PerfTestRunner.prepareToMeasureValuesAsync({ | 43 PerfTestRunner.measureValueAsync(message.data.value); |
| 52 done: function() { | 44 PerfTestRunner.gc(); |
| 53 var config = getConfigForPerformanceTest(connectionType, dataType, | 45 } else if (message.data.command === 'notifyAbort') { |
| 54 async, verifyData); | 46 PerfTestRunner.logFatalError("benchmark aborted"); |
| 55 doAction(config, isWorker, 'stop'); | 47 } |
| 56 }, | 48 }; |
| 57 unit: 'ms', | |
| 58 dromaeoIterationCount: numIterations | |
| 59 }); | |
| 60 | |
| 61 var config = getConfigForPerformanceTest(connectionType, dataType, async, | |
| 62 verifyData); | |
| 63 doAction(config, isWorker, benchmarkName); | |
| 64 } | |
| OLD | NEW |