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 (Macintosh; Intel Mac OS X 10.15; rv:130.0) Gecko/20100101 Firefox/130.0
Browser:
Firefox 130
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Vec2_int
913.1 Ops/sec
Vec2_float
944.7 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);