Skip to content

Instantly share code, notes, and snippets.

@JobLeonard
Last active April 21, 2025 10:50
Show Gist options
  • Save JobLeonard/11edd2526a572330033f098f22146e46 to your computer and use it in GitHub Desktop.
Save JobLeonard/11edd2526a572330033f098f22146e46 to your computer and use it in GitHub Desktop.
Compare two arrays of 100 elements
{"title":"Compare two arrays of 100 elements","initialization":"const arr1 = [], arr2 = [];\nfor (let i = 0; i < 100; i++) {\n arr1[i] = arr2[i] = Math.random();\n}","setup":"for (let i = 0; i < 100; i++) {\n arr1[i] = arr2[i] = Math.random();\n}\n// 50/50 chance of the whole array being equal or not,\n// if not one random element is different.\nif (Math.random() < 0.5) {\n arr1[Math.random() * arr1.length] = Math.random();\n}","tests":[{"name":"_.isEqual(arr1, arr2)","code":"_.isEqual(arr1, arr2)","results":{"aborted":false,"count":86648,"cycles":5,"hz":711006.5645514224,"stats":{"moe":2.8994813205090902e-8,"rme":2.0615502526761897,"sem":1.4793272043413725e-8,"deviation":9.923628569616094e-8,"mean":0.0000014064567753054503,"variance":9.847840398770077e-15,"numSamples":45},"times":{"cycle":0.12186666666666665,"elapsed":5.965,"period":0.0000014064567753054503,"timeStamp":1745232631371}},"platforms":{"Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0":{"aborted":false,"count":122999,"cycles":4,"hz":1501569.7701193246,"stats":{"moe":1.0097035291427465e-8,"rme":1.5161402961435444,"sem":5.151548618075237e-9,"deviation":4.088914953085661e-8,"mean":6.659697204216714e-7,"variance":1.6719225493567513e-15,"numSamples":63},"times":{"cycle":0.08191360964214517,"elapsed":5.94,"period":6.659697204216714e-7,"timeStamp":1745232595689}},"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36":{"aborted":false,"count":86648,"cycles":5,"hz":711006.5645514224,"stats":{"moe":2.8994813205090902e-8,"rme":2.0615502526761897,"sem":1.4793272043413725e-8,"deviation":9.923628569616094e-8,"mean":0.0000014064567753054503,"variance":9.847840398770077e-15,"numSamples":45},"times":{"cycle":0.12186666666666665,"elapsed":5.965,"period":0.0000014064567753054503,"timeStamp":1745232631371}}}},{"name":"arr1.toString() === arr2.toString()","code":"arr1.toString() === arr2.toString();","results":{"aborted":false,"count":7213,"cycles":4,"hz":89522.9981536042,"stats":{"moe":1.2815350555562974e-7,"rme":1.1472686041234548,"sem":6.538444161001518e-8,"deviation":5.27146220988519e-7,"mean":0.000011170314004499634,"variance":2.778831383024765e-13,"numSamples":65},"times":{"cycle":0.08057147491445586,"elapsed":5.843,"period":0.000011170314004499634,"timeStamp":1745232637342}},"platforms":{"Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0":{"aborted":false,"count":3372,"cycles":4,"hz":41596.1248216949,"stats":{"moe":3.006153288545102e-7,"rme":1.2504432742347067,"sem":1.5337516778291335e-7,"deviation":0.0000012270013422633068,"mean":0.00002404070100968731,"variance":1.5055322939159566e-12,"numSamples":64},"times":{"cycle":0.08106524380466561,"elapsed":5.904,"period":0.00002404070100968731,"timeStamp":1745232601634}},"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36":{"aborted":false,"count":7213,"cycles":4,"hz":89522.9981536042,"stats":{"moe":1.2815350555562974e-7,"rme":1.1472686041234548,"sem":6.538444161001518e-8,"deviation":5.27146220988519e-7,"mean":0.000011170314004499634,"variance":2.778831383024765e-13,"numSamples":65},"times":{"cycle":0.08057147491445586,"elapsed":5.843,"period":0.000011170314004499634,"timeStamp":1745232637342}}}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment