Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON.stringify.indexOf vs For loop 2
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/135.0.0.0 Safari/537.36
Browser:
Chrome 135
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
JSON.stringify.indexOf
46244.0 Ops/sec
For loop
2816219.8 Ops/sec
JSON.stringify.indexOf - attribute not found
109807.8 Ops/sec
For loop - attribute not found
3831074.0 Ops/sec
Script Preparation code:
a=[ { "AttributeName": "eee", "New": "Kate", "Old": "Winifred" }, { "AttributeName": "eee", "New": "Viviene", "Old": "Brooks" }, { "AttributeName": "bbb", "New": "Fayre", "Old": "Moyna" }, { "AttributeName": "bbb", "New": "Camile", "Old": "Tani" }, { "AttributeName": "aaa", "New": "Sherrie", "Old": "Cordi" }, { "AttributeName": "fff", "New": "Xylina", "Old": "Marcelline" }, { "AttributeName": "ccc", "New": "Ruthe", "Old": "Elie" }, { "AttributeName": "ccc", "New": "Marleah", "Old": "Minne" }, { "AttributeName": "eee", "New": "Felice", "Old": "Carolina" }, { "AttributeName": "bbb", "New": "Fina", "Old": "Alie" }, { "AttributeName": "bbb", "New": "Rubie", "Old": "Dennie" }, { "AttributeName": "bbb", "New": "Shirlee", "Old": "Dulcinea" }, { "AttributeName": "ddd", "New": "Dawn", "Old": "Rani" }, { "AttributeName": "eee", "New": "Courtnay", "Old": "Janeczka" }, { "AttributeName": "ccc", "New": "Jean", "Old": "Leona" }, { "AttributeName": "fff", "New": "Karina", "Old": "Rochette" }, { "AttributeName": "bbb", "New": "Chickie", "Old": "Penelopa" }, { "AttributeName": "fff", "New": "Lorenza", "Old": "Tera" }, { "AttributeName": "ddd", "New": "Meg", "Old": "Millie" }, { "AttributeName": "fff", "New": "Thalia", "Old": "Cam" }, { "AttributeName": "ddd", "New": "Lilith", "Old": "Jeanna" }, { "AttributeName": "aaa", "New": "Grier", "Old": "Yolane" }, { "AttributeName": "aaa", "New": "Lynnea", "Old": "Kerrin" }, { "AttributeName": "ccc", "New": "Ekaterina", "Old": "Jillayne" }, { "AttributeName": "aaa", "New": "Blinni", "Old": "Esmeralda" }, { "AttributeName": "eee", "New": "Kimberley", "Old": "Ulrike" }, { "AttributeName": "ccc", "New": "Shauna", "Old": "Sue" }, { "AttributeName": "bbb", "New": "Averyl", "Old": "Emylee" }, { "AttributeName": "fff", "New": "Ebonee", "Old": "Adore" }, { "AttributeName": "bbb", "New": "Sheree", "Old": "Phylis" }, { "AttributeName": "bbb", "New": "Roberta", "Old": "Constance" }, { "AttributeName": "eee", "New": "Agnese", "Old": "Jenilee" }, { "AttributeName": "fff", "New": "Ardeen", "Old": "Rubie" }, { "AttributeName": "ccc", "New": "Kathy", "Old": "Minda" }, { "AttributeName": "fff", "New": "Christal", "Old": "Stephanie" }, { "AttributeName": "ddd", "New": "Hettie", "Old": "Tersina" }, { "AttributeName": "bbb", "New": "Janey", "Old": "Bill" }, { "AttributeName": "eee", "New": "Ira", "Old": "Sallie" }, { "AttributeName": "fff", "New": "Tonia", "Old": "Clary" }, { "AttributeName": "fff", "New": "Paola", "Old": "Wilma" }, { "AttributeName": "aaa", "New": "Esmeralda", "Old": "Gui" }, { "AttributeName": "ccc", "New": "Sibella", "Old": "Sybille" }, { "AttributeName": "ccc", "New": "Beth", "Old": "Misha" }, { "AttributeName": "ddd", "New": "Olwen", "Old": "Alisha" }, { "AttributeName": "eee", "New": "Emelina", "Old": "Jany" }, { "AttributeName": "bbb", "New": "Hannis", "Old": "Sean" }, { "AttributeName": "ddd", "New": "Magdalena", "Old": "Kayla" }, { "AttributeName": "bbb", "New": "Roxane", "Old": "Mildrid" }, { "AttributeName": "eee", "New": "Steffane", "Old": "Rosene" }, { "AttributeName": "fff", "New": "Monika", "Old": "Philis" }, { "AttributeName": "aaa", "New": "Ulrike", "Old": "Ida" }, { "AttributeName": "ccc", "New": "Dale", "Old": "Wanda" }, { "AttributeName": "ccc", "New": "Kayla", "Old": "Ileana" }, { "AttributeName": "ddd", "New": "Gale", "Old": "Sarette" }, { "AttributeName": "bbb", "New": "Bobinette", "Old": "Imojean" }, { "AttributeName": "fff", "New": "Debee", "Old": "Trixi" }, { "AttributeName": "aaa", "New": "Almeta", "Old": "Linzy" }, { "AttributeName": "bbb", "New": "Zsa Zsa", "Old": "Heida" }, { "AttributeName": "fff", "New": "Beverley", "Old": "Elyssa" }, { "AttributeName": "bbb", "New": "Jaclyn", "Old": "Kenna" }, { "AttributeName": "fff", "New": "Katleen", "Old": "Sara-Ann" }, { "AttributeName": "ddd", "New": "Ebonee", "Old": "Lindie" }, { "AttributeName": "ccc", "New": "Meriel", "Old": "Berta" }, { "AttributeName": "ddd", "New": "Mary", "Old": "Leanna" }, { "AttributeName": "aaa", "New": "Robbi", "Old": "Kassey" }, { "AttributeName": "fff", "New": "Lexine", "Old": "Alejandra" }, { "AttributeName": "eee", "New": "Natka", "Old": "Kayla" }, { "AttributeName": "aaa", "New": "Tori", "Old": "Gabriellia" }, { "AttributeName": "ddd", "New": "Romona", "Old": "Anallese" }, { "AttributeName": "eee", "New": "Genevra", "Old": "Consuela" }, { "AttributeName": "ccc", "New": "Eolanda", "Old": "Joceline" }, { "AttributeName": "ccc", "New": "Tersina", "Old": "Kary" }, { "AttributeName": "bbb", "New": "Molli", "Old": "Annecorinne" }, { "AttributeName": "ddd", "New": "Rosaline", "Old": "Dari" }, { "AttributeName": "fff", "New": "Carol-Jean", "Old": "Kerrin" }, { "AttributeName": "eee", "New": "Alie", "Old": "Daune" }, { "AttributeName": "ccc", "New": "Carilyn", "Old": "Ekaterina" }, { "AttributeName": "fff", "New": "Bobinette", "Old": "Dagmar" }, { "AttributeName": "eee", "New": "Susette", "Old": "Anica" }, { "AttributeName": "ccc", "New": "Jordan", "Old": "Roberta" }, { "AttributeName": "eee", "New": "Dianemarie", "Old": "Eve" }, { "AttributeName": "bbb", "New": "Darlleen", "Old": "Katharina" }, { "AttributeName": "fff", "New": "Morganica", "Old": "Edee" }, { "AttributeName": "aaa", "New": "Sean", "Old": "Anthia" }, { "AttributeName": "aaa", "New": "Jennica", "Old": "Joy" }, { "AttributeName": "ddd", "New": "Briney", "Old": "Cyndie" }, { "AttributeName": "bbb", "New": "Iseabal", "Old": "Caritta" }, { "AttributeName": "fff", "New": "Melisent", "Old": "Merle" }, { "AttributeName": "fff", "New": "Glenda", "Old": "Lindie" }, { "AttributeName": "ddd", "New": "Ernesta", "Old": "Correy" }, { "AttributeName": "bbb", "New": "Jobi", "Old": "Julieta" }, { "AttributeName": "eee", "New": "Glynnis", "Old": "Maye" }, { "AttributeName": "bbb", "New": "Gratia", "Old": "Christy" }, { "AttributeName": "ddd", "New": "Celisse", "Old": "Chandra" }, { "AttributeName": "ddd", "New": "Brena", "Old": "Dominga" }, { "AttributeName": "eee", "New": "Dennie", "Old": "Celestyna" }, { "AttributeName": "fff", "New": "Gusty", "Old": "Darlleen" }, { "AttributeName": "ddd", "New": "Marleah", "Old": "Leanna" }, { "AttributeName": "bbb", "New": "Dawn", "Old": "Tiffie" }, { "AttributeName": "eee", "New": "Bobinette", "Old": "Selma" } ];
Tests:
JSON.stringify.indexOf
var changes = []; if (JSON.stringify(a).indexOf('aaa') > -1) { for(var i=0;i<a.length;i++) { if (JSON.stringify(a[i]).indexOf('aaa') > -1) { changes.push(a[i].New); } } }
For loop
var changes = []; for(var i=0;i<a.length;i++) { if (a[i].AttributeName === 'aaa') { changes.push(a[i].New); } }
JSON.stringify.indexOf - attribute not found
var changes = []; if (JSON.stringify(a).indexOf('iii') > -1) { for(var i=0;i<a.length;i++) { if (JSON.stringify(a[i]).indexOf('iii') > -1) { changes.push(a[i].New); } } }
For loop - attribute not found
var changes = []; for(var i=0;i<a.length;i++) { if (a[i].AttributeName === 'iii') { changes.push(a[i].New); } }