Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Inline anonymous classes
https://es.discourse.group/t/error-detail/1857/49
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Browser:
Chrome 108
Operating system:
Windows 7
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Anonymous redefined class
30122.4 Ops/sec
Predefined shared class
69363.8 Ops/sec
Builtin error with assigned properties
61794.2 Ops/sec
Script Preparation code:
class PredefinedError extends Error { foo = 5; bar = "foo"; } function throwShared() { throw new PredefinedError("Error message"); } function throwAnon() { throw new class extends Error { foo = 5; bar = "foo"; }("Error message"); } function throwExtended() { throw Object.assign(new Error("Error message"), { foo: 5, bar: "foo", }); }
Tests:
Anonymous redefined class
let x = 0; try { throwAnon(); } catch(e) { x += e.foo; }
Predefined shared class
let x = 0; try { throwShared(); } catch(e) { x += e.foo; }
Builtin error with assigned properties
let x = 0; try { throwExtended(); } catch(e) { x += e.foo; }