Add additional V8 performance tests (issue #960).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1292 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
00375f912c
commit
db530ec5e3
|
@ -88,6 +88,7 @@
|
|||
'tests/cefclient/res/logo.png',
|
||||
'tests/cefclient/res/other_tests.html',
|
||||
'tests/cefclient/res/performance.html',
|
||||
'tests/cefclient/res/performance2.html',
|
||||
'tests/cefclient/res/transparency.html',
|
||||
'tests/cefclient/res/window.html',
|
||||
'tests/cefclient/res/xmlhttprequest.html',
|
||||
|
|
|
@ -36,6 +36,7 @@ IDS_LOGO BINARY "res\\logo.png"
|
|||
IDS_OSRTEST BINARY "res\\osr_test.html"
|
||||
IDS_OTHER_TESTS BINARY "res\\other_tests.html"
|
||||
IDS_PERFORMANCE BINARY "res\\performance.html"
|
||||
IDS_PERFORMANCE2 BINARY "res\\performance2.html"
|
||||
IDS_TRANSPARENCY BINARY "res\\transparency.html"
|
||||
IDS_WINDOW BINARY "res\\window.html"
|
||||
IDS_XMLHTTPREQUEST BINARY "res\\xmlhttprequest.html"
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace {
|
|||
|
||||
const char kGetPerfTests[] = "GetPerfTests";
|
||||
const char kRunPerfTest[] = "RunPerfTest";
|
||||
const char kPerfTestReturnValue[] = "PerfTestReturnValue";
|
||||
|
||||
class V8Handler : public CefV8Handler {
|
||||
public:
|
||||
|
@ -68,6 +69,52 @@ class V8Handler : public CefV8Handler {
|
|||
val->SetValue(1, CefV8Value::CreateUInt(kPerfTests[i].iterations));
|
||||
retval->SetValue(i, val);
|
||||
}
|
||||
} else if (name == kPerfTestReturnValue) {
|
||||
if (arguments.size() == 0) {
|
||||
retval = CefV8Value::CreateInt(1);
|
||||
} else if (arguments.size() == 1 && arguments[0]->IsInt()) {
|
||||
int32 type = arguments[0]->GetIntValue();
|
||||
CefTime date;
|
||||
switch (type) {
|
||||
case 0:
|
||||
retval = CefV8Value::CreateUndefined();
|
||||
break;
|
||||
case 1:
|
||||
retval = CefV8Value::CreateNull();
|
||||
break;
|
||||
case 2:
|
||||
retval = CefV8Value::CreateBool(true);
|
||||
break;
|
||||
case 3:
|
||||
retval = CefV8Value::CreateInt(1);
|
||||
break;
|
||||
case 4:
|
||||
retval = CefV8Value::CreateUInt(1);
|
||||
break;
|
||||
case 5:
|
||||
retval = CefV8Value::CreateDouble(1.234);
|
||||
break;
|
||||
case 6:
|
||||
date.Now();
|
||||
retval = CefV8Value::CreateDate(date);
|
||||
break;
|
||||
case 7:
|
||||
retval = CefV8Value::CreateString("Hello, world!");
|
||||
break;
|
||||
case 8:
|
||||
retval = CefV8Value::CreateObject(NULL);
|
||||
break;
|
||||
case 9:
|
||||
retval = CefV8Value::CreateArray(8);
|
||||
break;
|
||||
case 10:
|
||||
// retval = CefV8Value::CreateFunction(...);
|
||||
exception = "Not implemented";
|
||||
break;
|
||||
default:
|
||||
exception = "Not supported";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -98,6 +145,9 @@ class RenderDelegate : public ClientApp::RenderDelegate {
|
|||
object->SetValue(kRunPerfTest,
|
||||
CefV8Value::CreateFunction(kRunPerfTest, handler),
|
||||
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||
object->SetValue(kPerfTestReturnValue,
|
||||
CefV8Value::CreateFunction(kPerfTestReturnValue, handler),
|
||||
V8_PROPERTY_ATTRIBUTE_READONLY);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<li><a href="http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True">HTML5 Video</a></li>
|
||||
<li><a href="http://tests/binding">JavaScript Binding</a></li>
|
||||
<li><a href="http://tests/performance">JavaScript Performance Tests</a></li>
|
||||
<li><a href="http://tests/performance2">JavaScript Performance (2) Tests</a></li>
|
||||
<li><a href="http://tests/window">JavaScript Window Manipulation</a></li>
|
||||
<li><a href="http://tests/localstorage">Local Storage</a></li>
|
||||
<li><a href="http://mrdoob.com/lab/javascript/requestanimationframe/">requestAnimationFrame</a></li>
|
||||
|
|
|
@ -0,0 +1,442 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Performance Tests (2)</title>
|
||||
<style>
|
||||
body { font-family: Tahoma, Serif; font-size: 9pt; }
|
||||
|
||||
.left { text-align: left; }
|
||||
.right { text-align: right; }
|
||||
.center { text-align: center; }
|
||||
|
||||
table.resultTable
|
||||
{
|
||||
border: 1px solid black;
|
||||
border-collapse: collapse;
|
||||
empty-cells: show;
|
||||
width: 100%;
|
||||
}
|
||||
table.resultTable td
|
||||
{
|
||||
padding: 2px 4px;
|
||||
border: 1px solid black;
|
||||
}
|
||||
table.resultTable > thead > tr
|
||||
{
|
||||
font-weight: bold;
|
||||
background: lightblue;
|
||||
}
|
||||
table.resultTable > tbody > tr:nth-child(odd)
|
||||
{
|
||||
background: white;
|
||||
}
|
||||
table.resultTable > tbody > tr:nth-child(even)
|
||||
{
|
||||
background: lightgray;
|
||||
}
|
||||
|
||||
.hide { display: none; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Performance Tests (2)</h1>
|
||||
|
||||
<form id="sForm" onsubmit="runTestSuite();return false">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="2">Settings:</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="right">Iterations:</td>
|
||||
<td><input id="sIterations" type="text" value="1000" required pattern="[0-9]+" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="right">Samples:</td>
|
||||
<td><input id="sSamples" type="text" value="100" required pattern="[0-9]+" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="right">Mode:</td>
|
||||
<td><input id="sAsync" name="sMode" type="radio" value="async" checked>Asynchronous</input>
|
||||
<input id="sSync" name="sMode" type="radio" value="sync">Synchronous</input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><button type="submit" id="sRun" autofocus>Run!</button></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
|
||||
<div><span id="statusBox"></span> <progress id="progressBox" value="0" style="display:none"></progress></div>
|
||||
|
||||
<div style="padding-top:10px; padding-bottom:10px">
|
||||
<table id="resultTable" class="resultTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="center" style="width:1%">Enabled</td>
|
||||
<td class="center" style="width:10%">Name</td>
|
||||
<td class="center" style="width:5%">Samples x Iterations</td>
|
||||
<td class="center" style="width:5%">Min, ms</td>
|
||||
<td class="center" style="width:5%">Avg, ms</td>
|
||||
<td class="center" style="width:5%">Max, ms</td>
|
||||
<td class="center" style="width:5%">Average calls/sec</td>
|
||||
<td class="center" style="width:5%">Measuring Inacurracy</td>
|
||||
<td class="center hide" style="width:5%">Memory, MB</td>
|
||||
<td class="center hide" style="width:5%">Memory delta, MB</td>
|
||||
<td class="center" style="width:55%">Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- result rows here -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
function getPrivateWorkingSet() {
|
||||
return 0; // TODO: window.PerfTestGetPrivateWorkingSet();
|
||||
}
|
||||
|
||||
var disableWarmUp = true;
|
||||
|
||||
var asyncExecution = true;
|
||||
var testIterations = 1000;
|
||||
var totalSamples = 100;
|
||||
var sampleDelay = 0;
|
||||
|
||||
var collectSamples = false;
|
||||
|
||||
var tests = [];
|
||||
var testIndex = -1;
|
||||
|
||||
function execTestFunc(test) {
|
||||
try {
|
||||
var begin = new Date();
|
||||
test.func(test.totalIterations);
|
||||
var end = new Date();
|
||||
return (end - begin);
|
||||
} catch (e) {
|
||||
test.error = e.toString();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function execTest(test) {
|
||||
if (disableWarmUp) { test.warmedUp = true; }
|
||||
|
||||
function nextStep() {
|
||||
if (asyncExecution) {
|
||||
setTimeout(function () { execTest(test); }, sampleDelay);
|
||||
} else {
|
||||
execTest(test);
|
||||
}
|
||||
}
|
||||
|
||||
function nextTest() {
|
||||
updateStatus(test);
|
||||
appendResult(test);
|
||||
|
||||
return execNextTest();
|
||||
}
|
||||
|
||||
updateStatus(test);
|
||||
if (!test.warmedUp) {
|
||||
execTestFunc(test);
|
||||
if (!test.error) {
|
||||
test.warmedUp = true;
|
||||
test.beginMemory = getPrivateWorkingSet();
|
||||
return nextStep();
|
||||
} else {
|
||||
return nextTest();
|
||||
}
|
||||
}
|
||||
|
||||
if (test.sample >= test.totalSamples) {
|
||||
test.avg = test.total / test.totalSamples;
|
||||
test.endMemory = getPrivateWorkingSet();
|
||||
return nextTest();
|
||||
}
|
||||
|
||||
if (test.skipped) return nextTest();
|
||||
|
||||
var elapsed = execTestFunc(test);
|
||||
if (!test.error) {
|
||||
test.total += elapsed;
|
||||
if (!test.min) test.min = elapsed;
|
||||
else if (test.min > elapsed) test.min = elapsed;
|
||||
if (!test.max) test.max = elapsed;
|
||||
else if (test.max < elapsed) test.max = elapsed;
|
||||
if (collectSamples) {
|
||||
test.results.push(elapsed);
|
||||
}
|
||||
test.sample++;
|
||||
return nextStep();
|
||||
} else {
|
||||
return nextTest();
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus(test) {
|
||||
var statusBox = document.getElementById("statusBox");
|
||||
var progressBox = document.getElementById("progressBox");
|
||||
|
||||
if (test.skipped || test.error || test.sample >= test.totalSamples) {
|
||||
statusBox.innerText = "";
|
||||
progressBox.style.display = "none";
|
||||
} else {
|
||||
statusBox.innerText = (testIndex + 1) + "/" + tests.length + ": " + test.name + " (" + test.sample + "/" + test.totalSamples + ")";
|
||||
progressBox.value = (test.sample / test.totalSamples);
|
||||
progressBox.style.display = "inline";
|
||||
}
|
||||
}
|
||||
|
||||
function appendResult(test) {
|
||||
if (test.name == "warmup") return;
|
||||
|
||||
var id = "testResultRow_" + test.index;
|
||||
|
||||
var nearBound = (test.max - test.avg) < (test.avg - test.min) ? test.max : test.min;
|
||||
var memoryDelta = test.endMemory - test.beginMemory;
|
||||
if (memoryDelta < 0) memoryDelta = "-" + Math.abs(memoryDelta).toFixed(2);
|
||||
else memoryDelta = "+" + Math.abs(memoryDelta).toFixed(2);
|
||||
|
||||
var markup = ["<tr id='" + id + "'>",
|
||||
"<td class='left'><input type='checkbox' id='test_enabled_", test.index ,"' ", (!test.skipped ? "checked" : "") ," /></td>",
|
||||
"<td class='left'>", test.name, "</td>",
|
||||
"<td class='right'>", test.totalSamples, "x", test.totalIterations, "</td>",
|
||||
"<td class='right'>", test.skipped || test.error || !test.prepared ? "-" : test.min.toFixed(2), "</td>",
|
||||
"<td class='right'>", test.skipped || test.error || !test.prepared ? "-" : test.avg.toFixed(2), "</td>",
|
||||
"<td class='right'>", test.skipped || test.error || !test.prepared ? "-" : test.max.toFixed(2), "</td>",
|
||||
"<td class='right'>", test.skipped || test.error || !test.prepared ? "-" : (test.totalIterations * 1000 / test.avg).toFixed(2), "</td>",
|
||||
"<td class='right'>", test.skipped || test.error || !test.prepared ? "-" : ("± " + (Math.abs(test.avg - nearBound) / (test.avg) * (100)).toFixed(2) + "%"), "</td>",
|
||||
"<td class='right hide'>", test.skipped || test.error || !test.prepared ? "-" : test.endMemory.toFixed(2), "</td>",
|
||||
"<td class='right hide'>", test.skipped || test.error || !test.prepared ? "-" : memoryDelta, "</td>",
|
||||
"<td class='left'>", test.description, test.error ? (test.description ? "<br/>" : "") + "<span style='color:red'>" + test.error + "</span>" : "", "</td>",
|
||||
"</tr>"
|
||||
].join("");
|
||||
// test.results.join(", "), "<br/>",
|
||||
|
||||
var row = document.getElementById(id);
|
||||
if (row) {
|
||||
row.outerHTML = markup;
|
||||
} else {
|
||||
var tbody = document.getElementById("resultTable").tBodies[0];
|
||||
tbody.insertAdjacentHTML("beforeEnd", markup);
|
||||
}
|
||||
}
|
||||
|
||||
function prepareQueuedTests() {
|
||||
testIndex = -1;
|
||||
for (var i = 0; i < tests.length; i++) {
|
||||
var test = tests[i];
|
||||
test.index = i;
|
||||
test.prepared = false;
|
||||
test.warmedUp = false;
|
||||
test.sample = 0;
|
||||
test.total = 0;
|
||||
test.results = [];
|
||||
test.error = false;
|
||||
test.min = null;
|
||||
test.avg = null;
|
||||
test.max = null;
|
||||
test.beginMemory = null;
|
||||
test.endMemory = null;
|
||||
test.totalIterations = parseInt(testIterations / test.complex);
|
||||
test.totalSamples = parseInt(totalSamples / test.complex);
|
||||
|
||||
var skipElement = document.getElementById('test_enabled_' + test.index);
|
||||
test.skipped = skipElement ? !skipElement.checked : (test.skipped || false);
|
||||
|
||||
if (test.totalIterations <= 0) test.totalIterations = 1;
|
||||
if (test.totalSamples <= 0) test.totalSamples = 1;
|
||||
|
||||
appendResult(test);
|
||||
test.prepared = true;
|
||||
}
|
||||
}
|
||||
|
||||
function queueTest(func, name, description) {
|
||||
var test;
|
||||
if (typeof func === "function") {
|
||||
test = {
|
||||
name: name,
|
||||
func: func,
|
||||
description: description
|
||||
};
|
||||
} else {
|
||||
test = func;
|
||||
}
|
||||
test.warmedUp = false;
|
||||
test.complex = test.complex || 1;
|
||||
tests.push(test);
|
||||
}
|
||||
|
||||
function execNextTest() {
|
||||
testIndex++;
|
||||
if (tests.length <= testIndex) {
|
||||
return testSuiteFinished();
|
||||
} else {
|
||||
return execTest(tests[testIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
function execQueuedTests() {
|
||||
prepareQueuedTests();
|
||||
execNextTest();
|
||||
}
|
||||
|
||||
function setSettingsState(disabled) {
|
||||
document.getElementById('sIterations').disabled = disabled;
|
||||
document.getElementById('sSamples').disabled = disabled;
|
||||
document.getElementById('sAsync').disabled = disabled;
|
||||
document.getElementById('sSync').disabled = disabled;
|
||||
document.getElementById('sRun').disabled = disabled;
|
||||
}
|
||||
|
||||
function testSuiteFinished() {
|
||||
setSettingsState(false);
|
||||
}
|
||||
|
||||
window.runTestSuite = function () {
|
||||
setSettingsState(true);
|
||||
|
||||
testIterations = parseInt(document.getElementById('sIterations').value);
|
||||
totalSamples = parseInt(document.getElementById('sSamples').value);
|
||||
asyncExecution = document.getElementById('sAsync').checked;
|
||||
|
||||
setTimeout(execQueuedTests, 0);
|
||||
}
|
||||
|
||||
setTimeout(prepareQueuedTests, 0);
|
||||
|
||||
// Test queue.
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue Default",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue();
|
||||
}
|
||||
},
|
||||
description: "No arguments, returns int32 value.",
|
||||
skipped: true,
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (0, Undefined)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(0);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns undefined value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (1, Null)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(1);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns null value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (2, Bool)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(2);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns bool value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (3, Int)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(3);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns int value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (4, UInt)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(4);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns uint value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (5, Double)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(5);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns double value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (6, Date)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(6);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns date value.",
|
||||
skipped: true,
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (7, String)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(7);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns string value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (8, Object)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(8);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns object value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (9, Array)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(9);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns array value."
|
||||
});
|
||||
|
||||
queueTest({
|
||||
name: "PerfTestReturnValue (10, Function)",
|
||||
func: function (count) {
|
||||
for (var i = 0; i < count; i++) {
|
||||
window.PerfTestReturnValue(10);
|
||||
}
|
||||
},
|
||||
description: "Int argument, returns function value.",
|
||||
skipped: true,
|
||||
});
|
||||
// add more tests to queueTest
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -50,6 +50,7 @@
|
|||
#define IDS_TRANSPARENCY 1009
|
||||
#define IDS_WINDOW 1010
|
||||
#define IDS_XMLHTTPREQUEST 1011
|
||||
#define IDS_PERFORMANCE2 1012
|
||||
|
||||
// Avoid files associated with MacOS
|
||||
#define _X86_
|
||||
|
|
|
@ -41,6 +41,7 @@ int GetResourceId(const char* resource_name) {
|
|||
{"osr_test.html", IDS_OSRTEST},
|
||||
{"other_tests.html", IDS_OTHER_TESTS},
|
||||
{"performance.html", IDS_PERFORMANCE},
|
||||
{"performance2.html", IDS_PERFORMANCE2},
|
||||
{"transparency.html", IDS_TRANSPARENCY},
|
||||
{"window.html", IDS_WINDOW},
|
||||
{"xmlhttprequest.html", IDS_XMLHTTPREQUEST},
|
||||
|
|
Loading…
Reference in New Issue