{"id":28970121,"url":"https://github.com/vasilii-kovalev/array-to-object-js-performance","last_synced_at":"2026-05-06T08:32:44.974Z","repository":{"id":300448087,"uuid":"1006180391","full_name":"vasilii-kovalev/array-to-object-js-performance","owner":"vasilii-kovalev","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-21T18:35:33.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-02T05:53:09.998Z","etag":null,"topics":["benchmark","bun","javascript","node"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vasilii-kovalev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-21T17:10:48.000Z","updated_at":"2025-06-21T18:35:36.000Z","dependencies_parsed_at":"2025-06-21T19:25:46.453Z","dependency_job_id":"8ced397f-5183-4172-a1b2-cee9dcdadd8e","html_url":"https://github.com/vasilii-kovalev/array-to-object-js-performance","commit_stats":null,"previous_names":["vasilii-kovalev/array-to-object-js-performance"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vasilii-kovalev/array-to-object-js-performance","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Farray-to-object-js-performance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Farray-to-object-js-performance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Farray-to-object-js-performance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Farray-to-object-js-performance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vasilii-kovalev","download_url":"https://codeload.github.com/vasilii-kovalev/array-to-object-js-performance/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vasilii-kovalev%2Farray-to-object-js-performance/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32684645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T02:33:58.958Z","status":"ssl_error","status_checked_at":"2026-05-06T02:33:39.611Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["benchmark","bun","javascript","node"],"created_at":"2025-06-24T10:19:54.598Z","updated_at":"2026-05-06T08:32:44.967Z","avatar_url":"https://github.com/vasilii-kovalev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Array-to-object performance in JavaScript\n\nThis repository contains benchmarks for different implementations of function, that turns an array of objects into an object with ids as keys and the objects as values. Like this:\n\n```\n[object1, object2] -\u003e { [object1.id]: object1, [object2.id]: object2 }\n```\n\nThe benchmark is implemented in [main.js](./main.js) file.\n\nThere are 3 implementation variants:\n1. Reduce + spread (`getItemsById1`)\n2. Reduce + mutation (`getItemsById2`)\n3. `for-of` + mutation (`getItemsById3`)\n\nFor benchmarks, a package called [mitata](https://github.com/evanwashere/mitata) is used, that Bun [recommends](https://bun.sh/docs/project/benchmarking#benchmarking-tools).\n\n## Results\n\n### Browser\n\nGoogle Chrome 137.0.7151.120 (64-bit)\n\n```\nclk: ~5.17 GHz\ncpu: null\nruntime: browser (null)\n\nbenchmark                   avg (min … max) p75 / p99    (min … top 1%)\n------------------------------------------- -------------------------------\nreduce + spread (10000)         7.09 s/iter    7.16 s  █                   \n                          (6.99 s … 7.19 s)    7.18 s ██▁▁██▁▁▁▁▁█▁██▁▁▁███\nreduce + mutation (10000)    356.97 µs/iter 400.00 µs    █   ▄             \n                      (200.00 µs … 2.10 ms) 800.00 µs ▃▁▁█▁▁▁█▁▁▂▁▁▁▁▁▁▁▁▁▁\nfor-of + mutation (10000)    342.85 µs/iter 400.00 µs    █                 \n                      (200.00 µs … 2.60 ms) 800.00 µs ▃▁▁█▁▁▁█▁▁▂▁▁▁▁▁▁▁▁▁▁\n```\n\nHighest/lowest ratio: 20,679.6\n\n#### How to check\n\nRun the following command in console:\n\n```bash\nnpm run dev\n```\n\nFollow the link to localhost and check the console in the browser.\n\n### Node.js\n\nVersion: 24.2.0\n\n```\nclk: ~5.45 GHz\ncpu: 13th Gen Intel(R) Core(TM) i9-13900KF\nruntime: node 24.2.0 (x64-win32)\n\nbenchmark                   avg (min … max) p75 / p99    (min … top 1%)\n------------------------------------------- -------------------------------\nreduce + spread (10000)         9.10 s/iter    9.11 s   █       █\n                          (9.01 s … 9.23 s)    9.20 s ▅▅█     ▅▅█▅       ▅▅\n                    ( 24.58 mb …  29.76 mb)  26.20 mb ███▁▁▁▁▁████▁▁▁▁▁▁▁██\n\nreduce + mutation (10000)    440.91 µs/iter 431.00 µs   █▆\n                      (369.30 µs … 3.44 ms) 788.40 µs ▇ ██\n                    (768.81 kb … 840.13 kb) 830.67 kb █▇██▃▃▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁\n\nfor-of + mutation (10000)    416.35 µs/iter 413.60 µs  █▂\n                      (344.80 µs … 3.35 ms) 783.20 µs  ██▂\n                    (768.76 kb …   1.35 mb) 934.26 kb █████▄▂▂▁▁▁▁▁▁▁▁▁▁▁▁▁\n```\n\nHighest/lowest ratio: 21,856.6\n\n#### How to check\n\nRun the following command in console:\n\n```bash\nnode main.js\n```\n\n### Bun\n\nVersion: 1.2.17\n\n```\nclk: ~3.66 GHz\ncpu: 13th Gen Intel(R) Core(TM) i9-13900KF\nruntime: bun 1.2.17 (x64-win32)\n\nbenchmark                   avg (min … max) p75 / p99    (min … top 1%)\n------------------------------------------- -------------------------------\nreduce + spread (10000)         1.67 s/iter    1.68 s    █         █       \n                          (1.64 s … 1.73 s)    1.69 s ▅  █ ▅   ▅  ▅█▅▅    ▅\n                    (  0.00  b …  15.98 mb)   2.28 mb █▁▁█▁█▁▁▁█▁▁████▁▁▁▁█\n\nreduce + mutation (10000)    459.78 µs/iter 424.40 µs █\n                      (380.00 µs … 3.33 ms)   2.40 ms █\n                    (  0.00  b …   4.74 mb)   3.36 kb █▄▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\n\nfor-of + mutation (10000)    441.00 µs/iter 405.80 µs █\n                      (362.60 µs … 3.44 ms)   3.00 ms █\n                    (  0.00  b …  12.00 kb)  20.70  b █▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁\n```\n\nHighest/lowest ratio: 3,786.8\n\n#### How to check\n\nRun the following command in console:\n\n```bash\nbun main.js\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasilii-kovalev%2Farray-to-object-js-performance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvasilii-kovalev%2Farray-to-object-js-performance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvasilii-kovalev%2Farray-to-object-js-performance/lists"}