Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2339)

Unified Diff: benchmarks/raytrace.js

Issue 4401: Introduce some checks to indicate that the benchmarks have run correctly.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 12 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « benchmarks/earley-boyer.js ('k') | benchmarks/richards.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: benchmarks/raytrace.js
===================================================================
--- benchmarks/raytrace.js (revision 362)
+++ benchmarks/raytrace.js (working copy)
@@ -13,6 +13,8 @@
]);
+var checkNumber;
+
// Create dummy objects if we're not running in a browser.
if (typeof document == 'undefined') {
document = { };
@@ -2669,6 +2671,13 @@
return result;
},
+ brightness : function() {
+ var r = Math.floor(this.red*255);
+ var g = Math.floor(this.green*255);
+ var b = Math.floor(this.blue*255);
+ return (r * 77 + g * 150 + b * 29) >> 8;
+ },
+
toString : function () {
var r = Math.floor(this.red*255);
var g = Math.floor(this.green*255);
@@ -3152,11 +3161,15 @@
this.canvas.fillStyle = color.toString();
this.canvas.fillRect (x * pxW, y * pxH, pxW, pxH);
} else {
+ if (x === y) {
+ checkNumber += color.brightness();
+ }
// print(x * pxW, y * pxH, pxW, pxH);
}
},
renderScene: function(scene, canvas){
+ checkNumber = 0;
/* Get canvas */
if (canvas) {
this.canvas = canvas.getContext("2d");
@@ -3179,6 +3192,9 @@
this.setPixel(x, y, color);
}
}
+ if (checkNumber !== 2321) {
+ throw new Error("Scene rendered incorrectly");
+ }
},
getPixelColor: function(ray, scene){
« no previous file with comments | « benchmarks/earley-boyer.js ('k') | benchmarks/richards.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698