Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Monomorphic vs Typed Monomorphic vs Empty Object prop assignment
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPad; CPU OS 18_1_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/132.0.6834.100 Mobile/15E148 Safari/604.1
Browser:
Chrome Mobile iOS 132
Operating system:
iOS 18.1.1
Device Platform:
Tablet
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Monomorphic
35.4M/s
Monomorphic Typed
34.7M/s
Empty Object
19.4M/s
View exact numbers
Test name
Executions per second
✓
Monomorphic
35,398,024 Ops/sec
Monomorphic Typed
34,668,316 Ops/sec
Empty Object
19,402,314 Ops/sec
Script Preparation code:
const source = { a: "", b: "", c: "", setA: function() { this.a = ""; }, setB: function() { this.b = ""; }, setC: function() { this.c = ""; }, }; function assignProps1(target) { for (const key in source) { target[key] = source[key]; } }; function assignProps2(target) { for (const key in source) { target[key] = source[key]; } }; function assignProps3(target) { for (const key in source) { target[key] = source[key]; } }; const noop = function() {}; function getMonoData() { return { a: null, b: null, c: null, setA: null, setB: null, setC: null }; } function getTypedData() { return { a: "", b: "", c: "", setA: noop, setB: noop, setC: noop }; } function getEmptyData() { return {}; }
Tests:
Monomorphic
assignProps1(getMonoData());
Monomorphic Typed
assignProps2(getTypedData());
Empty Object
assignProps3(getEmptyData());