Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object initialization direct vs. spread vs. Object.assign
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:129.0) Gecko/20100101 Firefox/129.0
Browser:
Firefox 129
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Direct
379109.8 Ops/sec
Spread
974225.7 Ops/sec
Object.assign
5191698.0 Ops/sec
Script Preparation code:
let props = [ "astId", "astCode", "astDescription", "sttId", "sttValue", "sttDescription", "asttId", "asttDescription", "astpId", "astpCode", "astpDescription", "astpMake", "astpModel", "astSerialNumber", "astAcquiredOn", "astInstalledOn", "astWarrantyExpiresOn", "pltId", "astIdParent", "astCodeParent", "astDescriptionParent", "pltPlantCode", "pltDescription", "wrcId", "wrcShortDesc", "wrcDescription", "mcnCode", "mcnDescription", "mchtDescription", "astIdAstAv", "purchaser", "purchase Date", ]; let empty = {}; props.forEach(prop => empty[prop] = null); function createEmptyRow() { const result = {}; props.forEach(prop => result[prop] = null); return result; } function copyEmptyRow() { return { ...empty } } function copyEmptyRowAssign() { return Object.assign({}, empty); }
Tests:
Direct
var data = createEmptyRow()
Spread
var data = copyEmptyRow()
Object.assign
var data = copyEmptyRowAssign()