RESOLVED FIXED 133054
TerrainPerf Performance testing, diamond-square terrain generation + canvas
https://bugs.webkit.org/show_bug.cgi?id=133054
Summary Performance testing, diamond-square terrain generation + canvas
Hunter Loftis
Reported 2014-05-18 14:14:31 PDT
This is an implementation of the diamond-square terrain generation algorithm commonly used to generate fractal-noise worlds in games. It stores height map data in a Float32Array and renders to a fixed-sized canvas. The benchmark averages the result of ten iterations.
Attachments
Implementation of diamond-square terrain generation (7.05 KB, text/html)
2014-05-18 14:15 PDT, Hunter Loftis
no flags
Patch (9.22 KB, patch)
2014-05-22 11:47 PDT, Geoffrey Garen
no flags
Patch (8.67 KB, patch)
2014-05-23 15:00 PDT, Geoffrey Garen
no flags
Patch (8.71 KB, patch)
2014-05-23 15:12 PDT, Geoffrey Garen
rniwa: review+
Hunter Loftis
Comment 1 2014-05-18 14:15:11 PDT
Created attachment 231665 [details] Implementation of diamond-square terrain generation
Geoffrey Garen
Comment 2 2014-05-22 11:47:41 PDT
Geoffrey Garen
Comment 3 2014-05-22 11:48:16 PDT
Thanks, Hunter. I did a bit more formatting to bring this up to WebKit coding standards, and turned it into a patch that can apply to the source tree.
Ryosuke Niwa
Comment 4 2014-05-22 12:02:34 PDT
Comment on attachment 231901 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=231901&action=review > PerformanceTests/Canvas/terrain.html:197 > + benchmark(function() { > + var terrain = new Terrain(9); > + terrain.generate(0.5); > + ctx.clearRect(0, 0, width, height); > + terrain.draw(ctx, width, height); > + }); We should use PerfTestRunner.measureTime or reportValueAsync so that perf bots would be able to run this test.
Ryosuke Niwa
Comment 5 2014-05-22 12:03:17 PDT
Comment on attachment 231901 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=231901&action=review > PerformanceTests/Canvas/terrain.html:41 > + Math.random = (function() { > + var seed = 49734321; > + return function() { > + /* The Jenkins hash function: > + <http://en.wikipedia.org/wiki/Jenkins_hash_function> > + <http://burtleburtle.net/bob/hash/integer.html> > + */ > + seed = ((seed + 0x7ed55d16) + (seed << 12)) & 0xffffffff; > + seed = ((seed ^ 0xc761c23c) ^ (seed >>> 19)) & 0xffffffff; > + seed = ((seed + 0x165667b1) + (seed << 5)) & 0xffffffff; > + seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff; > + seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff; > + seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff; > + return (seed & 0xfffffff) / 0x10000000; > + }; > + })(); This is included in PerformanceTests/resources/runner.js
Ryosuke Niwa
Comment 6 2014-05-22 12:06:21 PDT
Comment on attachment 231901 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=231901&action=review >> PerformanceTests/Canvas/terrain.html:197 >> + }); > > We should use PerfTestRunner.measureTime or reportValueAsync so that perf bots would be able to run this test. I think all you need to do is include ../resources/runner.js and then do: PerfTestRunner.measureTime({run: function () { var terrain = new Terrain(9); ... }})
Geoffrey Garen
Comment 7 2014-05-23 15:00:23 PDT
Geoffrey Garen
Comment 8 2014-05-23 15:12:20 PDT
Geoffrey Garen
Comment 9 2014-05-23 15:37:55 PDT
Note You need to log in before you can comment on or make changes to this bug.