Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
multiple iteration vs single iteration diff size
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Browser:
Chrome 145
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one month ago
Test name
Executions per second
Multiple iteration
2784.4 Ops/sec
Single iteration
62260.5 Ops/sec
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
function randomHash() { return Math.random().toString(36).substring(2, 12); } function generateDataset(size) { const contactsToSync = []; const syncedContacts = []; const phoneHashes = []; const emailHashes = []; for (let i = 0; i < size; i++) { const phoneHash = randomHash(); const emailHash = randomHash(); phoneHashes.push(phoneHash); emailHashes.push(emailHash); contactsToSync.push({ name: "Contact " + i, phoneNumberHashed: phoneHash, emailAddressHashed: emailHash, }); } for (let i = 0; i < (size - 300); i++) { const usePhone = Math.random() > 0.5; syncedContacts.push({ matched_by: { phone_hash: usePhone ? phoneHashes[Math.floor(Math.random() * size)] : undefined, email_hash: !usePhone ? emailHashes[Math.floor(Math.random() * size)] : undefined, }, contact: { paytag: "user_" + i, }, }); } return { contactsToSync, syncedContacts }; } var { contactsToSync, syncedContacts } = generateDataset(500);
Tests:
Multiple iteration
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ let matchedPhoneNumberHashes = []; let matchedEmailAddressHashes = []; let paytagToContactBookNameMap = {}; matchedPhoneNumberHashes = syncedContacts .map((contact) => contact.matched_by.phone_hash) .filter((item) => !!item); matchedEmailAddressHashes = syncedContacts .map((contact) => contact.matched_by.email_hash) .filter((item) => !!item); syncedContacts.forEach((syncedContact) => { const contactBookName = contactsToSync.find( (contact) => contact.phoneNumberHashed === syncedContact.matched_by.phone_hash || contact.emailAddressHashed === syncedContact.matched_by.email_hash, )?.name; if (contactBookName) { paytagToContactBookNameMap[syncedContact.contact.paytag] = contactBookName; } });
Single iteration
let matchedPhoneNumberHashes = []; let matchedEmailAddressHashes = []; let paytagToContactBookNameMap = {}; // Build fast lookup tables once let phoneHashToName = new Map(); let emailHashToName = new Map(); for (const contact of contactsToSync) { if (contact.phoneNumberHashed && !phoneHashToName.has(contact.phoneNumberHashed)) { phoneHashToName.set(contact.phoneNumberHashed, contact.name); } if (contact.emailAddressHashed && !emailHashToName.has(contact.emailAddressHashed)) { emailHashToName.set(contact.emailAddressHashed, contact.name); } } // Single pass over syncedContacts for (const syncedContact of syncedContacts) { const phoneHash = syncedContact.matched_by.phone_hash; const emailHash = syncedContact.matched_by.email_hash; if (phoneHash) matchedPhoneNumberHashes.push(phoneHash); if (emailHash) matchedEmailAddressHashes.push(emailHash); const contactBookName = (phoneHash ? phoneHashToName.get(phoneHash) : undefined) ?? (emailHash ? emailHashToName.get(emailHash) : undefined); if (contactBookName) { paytagToContactBookNameMap[syncedContact.contact.paytag] = contactBookName; } }