This repository has been archived by the owner on Sep 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
Test optionating #2
Open
deepak1556
wants to merge
3
commits into
google:master
Choose a base branch
from
deepak1556:test_optionating
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−25
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,19 @@ var preventContextMenuAndSelection = function(e) { | |
return false; | ||
} | ||
|
||
var parseUrl = function(q) { | ||
var exp = q.substr(q.indexOf("=") + 1, q.length); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of using substr/indexOf, you can use one regex to do it all: /(?:^|&)parameterName=([^&]+)/ will match parameterName anywhere in the query string and give you the value as the first group of the match. |
||
return exp.split(exp.match(/\D/)); | ||
}; | ||
|
||
var genArray = function(range) { | ||
var arr = new Array(); | ||
for(var i = 0; i < range; i++) { | ||
arr[i] = i+1; | ||
} | ||
|
||
return arr; | ||
} | ||
|
||
var addEvents = function() { | ||
document.addEventListener('keydown', preventContextMenuAndSelection); | ||
|
@@ -142,12 +155,26 @@ var spinDone = true; | |
workerHandlers.spin = function(e) { | ||
spinDone = true; | ||
}; | ||
workerHandlers.gcLoad = function(e) { | ||
return test.finishedMeasuring = true; | ||
}; | ||
|
||
// We don't use getPrefixed here because we want to replace the unprefixed version with the prefixed one if it exists. | ||
if (worker) { | ||
worker.postMessage = worker.webkitPostMessage || worker.mozPostMessage || worker.oPostMessage ||worker.msPostMessage || worker.postMessage; | ||
} | ||
|
||
var workerGCLoad = function() { | ||
if (!worker) | ||
return fail(this); | ||
var test = this; | ||
try { | ||
worker.postMessage({test: 'gcLoad'}); | ||
} catch(e) { | ||
fail(this); | ||
} | ||
} | ||
|
||
var checkTransferables = function() { | ||
if (!worker || !window.ArrayBuffer) | ||
return fail(this); | ||
|
@@ -427,6 +454,9 @@ var tests = [ | |
{ name: 'Image loading jank', | ||
info: 'Tests responsiveness during image loading.', | ||
test: testJank, blocker: loadGiantImage, report: ['css', 'js', 'scroll'] }, | ||
{ name: 'Worker GC Load', | ||
info: 'Tests if worker GC affects main page.', | ||
test: testJank, blocker: workerGCLoad, report: ['js', 'scroll'] }, | ||
// These tests work, but are disabled for now to focus on the latency test. | ||
// { name: 'requestAnimationFrame', test: checkName, toCheck: 'requestAnimationFrame' }, | ||
// { name: 'Canvas 2D', test: checkName, toCheck: 'HTMLCanvasElement' }, | ||
|
@@ -474,29 +504,39 @@ var tests = [ | |
// { name: 'Worker GC doesn\'t affect main page', test: testJank, blocker: workerGCLoad }, | ||
]; | ||
|
||
for (var i = 0; i < tests.length; i++) { | ||
var test = tests[i]; | ||
var row = document.createElement('tr'); | ||
var nameCell = document.createElement('td'); | ||
var resultCell = document.createElement('td'); | ||
var infoCell = document.createElement('td'); | ||
nameCell.className = 'testName'; | ||
nameCell.textContent = test.name; | ||
var description = document.createElement('div'); | ||
description.className = 'testDescription'; | ||
nameCell.appendChild(description); | ||
if (test.info) { | ||
description.textContent = test.info; | ||
if(window.location.search) { | ||
var testIndexes = parseUrl(window.location.search); | ||
} | ||
|
||
var testList = testIndexes || genArr(tests.length); | ||
|
||
for (var i = 0; i < testList.length; i++) { | ||
if(testList[i] <= tests.length) { | ||
var test = tests[testList[i]-1]; | ||
var row = document.createElement('tr'); | ||
var nameCell = document.createElement('td'); | ||
var resultCell = document.createElement('td'); | ||
var infoCell = document.createElement('td'); | ||
nameCell.className = 'testName'; | ||
nameCell.textContent = test.name; | ||
var description = document.createElement('div'); | ||
description.className = 'testDescription'; | ||
nameCell.appendChild(description); | ||
if (test.info) { | ||
description.textContent = test.info; | ||
} | ||
resultCell.className = 'testResult'; | ||
test.resultCell = document.createElement('div'); | ||
resultCell.appendChild(test.resultCell); | ||
infoCell.className = 'testInfo'; | ||
test.infoCell = infoCell; | ||
row.appendChild(nameCell); | ||
row.appendChild(resultCell); | ||
row.appendChild(infoCell); | ||
table.appendChild(row); | ||
} else { | ||
document.getElementById("progressMessage").textContent = "Error: test index "+ testList[i] +" out of range."; | ||
} | ||
resultCell.className = 'testResult'; | ||
test.resultCell = document.createElement('div'); | ||
resultCell.appendChild(test.resultCell); | ||
infoCell.className = 'testInfo'; | ||
test.infoCell = infoCell; | ||
row.appendChild(nameCell); | ||
row.appendChild(resultCell); | ||
row.appendChild(infoCell); | ||
table.appendChild(row); | ||
} | ||
|
||
var nextTestIndex = 0; | ||
|
@@ -509,13 +549,13 @@ var runNextTest = function(previousTest) { | |
return; | ||
} | ||
previousTest.finished = true; | ||
if (previousTest != tests[nextTestIndex - 1]) { | ||
if (previousTest != tests[testList[nextTestIndex - 1]-1]) { | ||
previousTest.infoCell.textContent = "Error: test sent results out of order"; | ||
return; | ||
} | ||
} | ||
var testIndex = nextTestIndex++; | ||
if (testIndex >= tests.length) { | ||
if (testIndex >= testList.length) { | ||
// All tests successfully completed. Report the overall score as a number out of 10. | ||
var scoreRatio = totalScore / totalPossibleScore; | ||
var score = document.getElementById('score'); | ||
|
@@ -528,7 +568,7 @@ var runNextTest = function(previousTest) { | |
// End the test run. | ||
return; | ||
} | ||
var test = tests[testIndex]; | ||
var test = tests[testList[testIndex]-1]; | ||
test.infoCell.textContent = ''; | ||
test.resultCell.textContent = '⋯'; | ||
setTimeout(function() { checkTimeout(test); }, 50000); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this page needs a list of tests. I prefer not to have the list of tests in two places. I'll definitely forget to update one or the other.