Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Initialize Vec2 with int vs float
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0
Browser:
Firefox 135
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Vec2_int
294.2 Ops/sec
Vec2_float
288.0 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Tests:
Vec2_int
class Vec2_int { x = 0; y = 0; randomize() { this.x = Math.random(); this.y = Math.random(); } length2() { return this.x * this.x + this.y * this.y; } length() { return Math.sqrt(this.length2()); } } let num = 10000 let sum = 0 for (let i=0; i<num; i++) { let v = new Vec2_int(); v.randomize(); sum += v.length(); } sum /= num; console.log(sum);
Vec2_float
class Vec2_float { x = 0.5; y = 0.5; randomize() { this.x = Math.random(); this.y = Math.random(); } length2() { return this.x * this.x + this.y * this.y; } length() { return Math.sqrt(this.length2()); } } let num = 10000 let sum = 0 for (let i=0; i<num; i++) { let v = new Vec2_float(); v.randomize(); sum += v.length(); } sum /= num; console.log(sum);