Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
ES6 Class vs Function with float32array vs Function with Array 2
(version: 1)
Comparing performance of:
ES6 Class vs Function float32array vs Function array
Created:
one year ago
by:
Guest
Jump to the latest result
Tests:
ES6 Class
class Point { constructor(x, y){ this.x = x; this.y = y; } add(point){ return new Point(this.x + point.x, this.y + point.y); } sub(point){ return new Point(this.x - point.x, this.y - point.y); } toFloat32Array(){ return new Float32Array([this.x,this.y]) } } var p1 = new Point(10, 10); var p2 = new Point(10, -10); var sum = p1.add(p2); var dif = p1.sub(p2); var f32 = p1.toFloat32Array();
Function float32array
function create_point(x,y){ return new Float32Array([ x , y ]); } function add_points(a,b){ return new Float32Array( [ a[0] + b[0] , a[1] + b[1] ] ); } function sub_points(a,b){ return new Float32Array( [ a[0] - b[0] , a[1] - b[1] ] ); } var p1 = create_point(10,10); var p2 = create_point(10,-10); var sum = add_points(p1,p2); var dif = sub_points(p1,p2); var f32 = p1
Function array
function create_point(x,y){ return [ x , y ]; } function add_points(a,b){ return [ a[0] + b[0] , a[1] + b[1] ]; } function sub_points(a,b){ return [ a[0] - b[0] , a[1] - b[1] ]; } function to_32(a){ return new Float32Array(a); } var p1 = create_point(10,10); var p2 = create_point(10,-10); var sum = add_points(p1,p2); var dif = sub_points(p1,p2); var f32 = to_32(p1);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
ES6 Class
Function float32array
Function array
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser/OS:
Chrome 130 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
ES6 Class
287064.7 Ops/sec
Function float32array
1069817.8 Ops/sec
Function array
4028283.5 Ops/sec
Related benchmarks:
literals vs classes
Instantiation via ES6 Class vs Prototype vs Object Literal
ES6 Class vs Prototype vs Object Literal vs Object & Functions
ES6 Class vs Prototype vs Object Literal vs Object & Functions 2
ES6 Class vs Prototype vs Object Literal n moar
ES6 Class vs Prototype vs Object Literal vs Object & Functions [rW@B8]
ES6 Class vs Prototype vs Object Literal vs Function vs Function with object destructuring
aefq4fghtdgf3d2w
ES6 Class vs Function with float32array vs Function with Array
Comments
Confirm delete:
Do you really want to delete benchmark?