diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2017-04-10 20:34:39 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-04-20 18:46:35 +0300 |
commit | 51ebb96b1da5217d6742ba05ea67a66c7787f0da (patch) | |
tree | 1871a944f7abd6bc35db4a8126e704f8981ef87d /platform/node/test/benchmark.js | |
parent | d767545f72e5a3e05d37e1d71b2c1f9a86522ca9 (diff) | |
download | qtlocation-mapboxgl-51ebb96b1da5217d6742ba05ea67a66c7787f0da.tar.gz |
[node] Add map.cancel()
Cancels an ongoing rendering.
Diffstat (limited to 'platform/node/test/benchmark.js')
-rw-r--r-- | platform/node/test/benchmark.js | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/platform/node/test/benchmark.js b/platform/node/test/benchmark.js index 38c416ed34..50f6353bca 100644 --- a/platform/node/test/benchmark.js +++ b/platform/node/test/benchmark.js @@ -9,8 +9,8 @@ var firstRequest = "mapbox://sprites/mapbox/streets-v9@2x.json"; var params = { mapPoolSize: 10, numRenderings: 1000, - failurePercentage: 0, - timeoutPercentage: 0, + failurePercentage: 10, + timeoutPercentage: 10, renderingTimeout: 5000, ratio: 2 }; @@ -20,7 +20,7 @@ test('Benchmark', function(t) { var renderCount = 0; var failureCount = 0; - var timeoutCount = 0; + var cancelCount = 0; var options = { request: function(req, callback) { @@ -70,15 +70,13 @@ test('Benchmark', function(t) { t.end(); console.timeEnd('Time'); console.log('Failures: ' + failureCount); - console.log('Timeouts: ' + timeoutCount); + console.log('Canceled: ' + cancelCount); return; } var mapTimeout = setTimeout(function() { - map.release(); - mapPool.push(new mbgl.Map(options)); - timeoutCount += 1; + map.cancel(); }, params.renderingTimeout); map.render({ zoom: 16 }, function(err, pixels) { @@ -89,13 +87,15 @@ test('Benchmark', function(t) { failureCount += 1; } + if (err.message == 'Canceled') { + cancelCount += 1; + } + + // We cancel the request before it gets a + // timeout error from the file source. if (err.message == 'Timeout') { t.fail('should never happen'); } - - map.release(); - mapPool.push(new mbgl.Map(options)); - return; } mapPool.push(map); |