Adding a runner for WMS capabilities parsing benchmarks.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9659 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
53
tests/speed/wmscaps.html
Normal file
53
tests/speed/wmscaps.html
Normal file
@@ -0,0 +1,53 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>WMS Capabilities Speed Test</test>
|
||||
<script src="../../lib/OpenLayers.js"></script>
|
||||
<script src="wmscaps.js"></script>
|
||||
<script>
|
||||
var data;
|
||||
var stats = [];
|
||||
|
||||
function parseCaps(id, done) {
|
||||
var format = new OpenLayers.Format.WMSCapabilities();
|
||||
data = format.read(caps);
|
||||
done(id);
|
||||
}
|
||||
|
||||
function run(func, x) {
|
||||
document.getElementById("out").innerHTML = "running ..."
|
||||
var starts = {};
|
||||
var elapsed = 0;
|
||||
completed = 0;
|
||||
function callback(id) {
|
||||
elapsed += new Date() - starts[id];
|
||||
++completed;
|
||||
if (completed === x) {
|
||||
report(x, elapsed);
|
||||
}
|
||||
}
|
||||
var runner;
|
||||
for (var i=0; i<x; i++) {
|
||||
runner = createRunner(i, starts, func, callback);
|
||||
window.setTimeout(runner, 0);
|
||||
}
|
||||
}
|
||||
|
||||
function createRunner(id, starts, func, done) {
|
||||
return function() {
|
||||
starts[id] = new Date();
|
||||
func(id, done);
|
||||
}
|
||||
}
|
||||
|
||||
function report(x, elapsed) {
|
||||
document.getElementById("out").innerHTML = elapsed + " ms for " + x + " runs (" + elapsed/x + " ms average)";
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a onclick="javascript:run(parseCaps, 5); return false" href="#">Run</a>
|
||||
<div id="out"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
4956
tests/speed/wmscaps.js
Normal file
4956
tests/speed/wmscaps.js
Normal file
File diff suppressed because it is too large
Load Diff
4954
tests/speed/wmscaps.xml
Normal file
4954
tests/speed/wmscaps.xml
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user