{"id":15710573,"url":"https://github.com/ivanhuay/micron-test-for-await","last_synced_at":"2026-04-24T21:33:29.871Z","repository":{"id":75932944,"uuid":"194310234","full_name":"ivanhuay/micron-test-for-await","owner":"ivanhuay","description":"benchmark for await vs for + await","archived":false,"fork":false,"pushed_at":"2019-06-28T17:27:06.000Z","size":35,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-05T04:26:26.054Z","etag":null,"topics":["benchmark","benchmarking","javascript","micron","micron-runner","node","test"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"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/ivanhuay.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}},"created_at":"2019-06-28T17:24:46.000Z","updated_at":"2019-07-02T11:50:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"4fd0da68-4d66-48fc-a19e-ea4872651f4c","html_url":"https://github.com/ivanhuay/micron-test-for-await","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ivanhuay/micron-test-for-await","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanhuay%2Fmicron-test-for-await","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanhuay%2Fmicron-test-for-await/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanhuay%2Fmicron-test-for-await/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanhuay%2Fmicron-test-for-await/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivanhuay","download_url":"https://codeload.github.com/ivanhuay/micron-test-for-await/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivanhuay%2Fmicron-test-for-await/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32241794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: 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","benchmarking","javascript","micron","micron-runner","node","test"],"created_at":"2024-10-03T21:08:41.622Z","updated_at":"2026-04-24T21:33:29.851Z","avatar_url":"https://github.com/ivanhuay.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Micron Benchmark For await vs await\nThis is a benchmark to analize the performance between the two functions `for + await` vs `for-await`.\n\n## Motivation\nIn this benchmark we measure the performance variation using this two funcions:\n\n```javascript\nfor (var i = 0; i \u003c limit; i++) {\n  let elm = await getResource();\n}\n```\nvs\n```javascript\ndata = {\n  [Symbol.asyncIterator]() {\n    return {\n      i: 0,\n      next() {\n        if (this.i \u003c limit) {\n          this.i++;\n          return getResource()\n              .then((value)=\u003e({value, done: false}));\n        }\n        return Promise.resolve({ done: true });\n      }\n    };\n  }\n};\nfor await (let prom of data) {\n}\n```\n\n`for await` looks simpler but you have to use an `AsyncIterator` that isn't simpler than using an array.\n\n## Results\n\nBoth functions have similar performance but `for await` has more complexity because of the AsyncIterator. Only if we were using an async iterator previously the `for next` is better than a simple `for + await`.\n\n[view results HERE](https://ivanhuay.github.io/micron-test-for-await/)\n![Alt image](https://github.com/ivanhuay/micron-test-for-await/blob/master/img/img.jpg?raw=true)\n\n## run the test\n\n```\ngit clone https://github.com/ivanhuay/micron-test-for-await.git\n\ncd micron-test-for-await\n\nnpm i\n\nnpm run test\n```\n\nafter running that the results should be on the docs folder.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanhuay%2Fmicron-test-for-await","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivanhuay%2Fmicron-test-for-await","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivanhuay%2Fmicron-test-for-await/lists"}