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

Side by Side Diff: chrome/test/data/third_party/spaceport/js/index.js

Issue 10154006: Add test data for spaceport benchmark. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 define([ 'tests/performance', 'testDom', 'testRunner', 'tables', 'util/report', 'util/ensureCallback', 'fullReport' ], function (performance, testDom, testRunne r, tables, report, ensureCallback, fullReport) {
2 function testDone(err, name, results) {
3 var domId = name.replace(/[^a-z0-9]/gi, '-');
4 testDom.endTest(domId, err, results);
5 }
6
7 function allTestsDone(err, results) {
8 if (err) {
9 console.error(err);
10 return;
11 }
12
13 var allTestResultsEl = document.getElementById('all-test-results');
14 allTestResultsEl.textContent = fullReport.csvReport(results);
15 }
16
17 registerOnLoad(function () {
18 var table = report.tableTemplate('performance-sprites', report.makeTable Layout(tables.performance.sprites));
19 var tablePlaceholder = document.getElementById('performance-sprites-plac eholder');
20 tablePlaceholder.parentNode.replaceChild(table, tablePlaceholder);
21
22 table = report.tableTemplate('performance-text', report.makeTableLayout( tables.performance.text));
23 tablePlaceholder = document.getElementById('performance-text-placeholder ');
24 tablePlaceholder.parentNode.replaceChild(table, tablePlaceholder);
25
26 var performanceTestsRunning = false;
27 var runPerformanceTestsButton = document.getElementById('start-performan ce-tests');
28 var uploadPerformanceTestsButton = document.getElementById('upload-perfo rmance-tests');
29
30 function setRunning(isRunning) {
31 performanceTestsRunning = isRunning;
32 runPerformanceTestsButton.disabled = isRunning;
33 uploadPerformanceTestsButton.disabled = isRunning;
34 }
35
36 function runPerformanceTests(callback) {
37 callback = ensureCallback(callback);
38
39 testRunner.run('performance', performance, {
40 done: function (err, results) {
41 allTestsDone(err, results);
42 callback(err, results);
43 },
44 step: function (err, name, results) {
45 shortName = name.replace('performance.sprites.image.', '');
46 if (results) {
47 console.log(shortName + ": " + results.objectCount);
48 } else {
49 console.log(shortName + ": 0");
50 }
51 return testDone(err, name, results);
52 }
53 });
54 }
55
56 function runAndUploadPerformanceTests(callback) {
57 callback = ensureCallback(callback);
58
59 runPerformanceTests(function (err, results) {
60 if (err) return callback(err);
61
62 var xhr = new XMLHttpRequest();
63 xhr.onreadystatechange = function () {
64 if (xhr.readyState === 4) {
65 // Complete
66 callback(null);
67 }
68 };
69 xhr.open('POST', 'results', true);
70 xhr.send(JSON.stringify({
71 agentMetadata: fullReport.getAgentMetadata(),
72 results: results
73 }));
74 });
75 }
76
77 setRunning(false);
78
79 runPerformanceTestsButton.addEventListener('click', function () {
80 if (performanceTestsRunning) {
81 throw new Error('Tests already running');
82 }
83
84 setRunning(true);
85
86 runPerformanceTests(function (err, results) {
87 setRunning(false);
88 });
89 }, false);
90
91 uploadPerformanceTestsButton.addEventListener('click', function () {
92 if (performanceTestsRunning) {
93 throw new Error('Tests already running');
94 }
95
96 setRunning(true);
97
98 runAndUploadPerformanceTests(function (err, results) {
99 setRunning(false);
100 });
101 }, false);
102
103 var getVars = { };
104 if (/^\?/.test(location.search)) {
105 location.search.substr(1).split(/&/g).forEach(function (part) {
106 var equalsIndex = part.indexOf('=');
107
108 if (equalsIndex >= 0) {
109 getVars[part.substr(0, equalsIndex)] = part.substr(equalsInd ex + 1);
110 } else {
111 getVars[part] = true;
112 }
113 });
114 }
115
116 if ('auto' in getVars) {
117 runPerformanceTests();
118 }
119 });
120 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698