{"id":23366716,"url":"https://github.com/d8corp/perfocode","last_synced_at":"2025-04-07T23:15:44.190Z","repository":{"id":57322104,"uuid":"309399842","full_name":"d8corp/perfocode","owner":"d8corp","description":"Performance checker","archived":false,"fork":false,"pushed_at":"2020-11-15T18:00:08.000Z","size":756,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T06:35:44.094Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/d8corp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-02T14:44:52.000Z","updated_at":"2020-11-15T17:59:33.000Z","dependencies_parsed_at":"2022-08-25T22:42:27.607Z","dependency_job_id":null,"html_url":"https://github.com/d8corp/perfocode","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Fperfocode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Fperfocode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Fperfocode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/d8corp%2Fperfocode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/d8corp","download_url":"https://codeload.github.com/d8corp/perfocode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744328,"owners_count":20988783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-21T14:17:24.859Z","updated_at":"2025-04-07T23:15:44.153Z","avatar_url":"https://github.com/d8corp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# perfocode\n[![NPM](https://img.shields.io/npm/v/perfocode.svg)](https://github.com/d8corp/perfocode/blob/master/CHANGELOG.md)\n[![minzipped size](https://img.shields.io/bundlephobia/minzip/perfocode)](https://bundlephobia.com/result?p=perfocode)\n[![downloads](https://img.shields.io/npm/dm/perfocode.svg)](https://www.npmjs.com/package/perfocode)\n[![license](https://img.shields.io/npm/l/perfocode)](https://github.com/d8corp/perfocode/blob/master/LICENSE)  \nThe simplest performance checker.\n### Installation\nnpm\n```bash\nnpm i perfocode -D\n```\nyarn\n```bash\nyarn add perfocode -D\n```\n### Using\nCreate `index.js` with the next code.\n```javascript\nconst {perfocode, describe, test} = require('perfocode')\n\nperfocode('output-file', () =\u003e {\n  describe('getters vs methods', () =\u003e {\n    class GetterVsMethod {\n      constructor () {\n        this._value = 0\n      }\n      get value () {\n        return this._value\n      }\n      getValue () {\n        return this._value\n      }\n    }\n\n    const getterVsMethod = new GetterVsMethod()\n\n    test('getter', () =\u003e getterVsMethod.value)\n    test('method', () =\u003e getterVsMethod.getValue())\n  })\n})\n```\nRun the file.\n```bash\nnode index.js\n```\nWhen a compare file does not exist you will see only current results.\n\n![](https://raw.githubusercontent.com/d8corp/perfocode/main/1.png)\n\nPress `enter` if you wanna save the results to `output-file.json`.  \n\nRun the test again, and you will see the difference between the current and the previous results.\n\n![](https://raw.githubusercontent.com/d8corp/perfocode/main/2.png)\n\nAny next running will show `min`, `max`, `previous min`, `previous max`, `current value` and `average value`.  \n\n**Average value** has **yellow** color.\nThen you can see 3 numbers.\nThe **first** one is the **minimum** value.\nThe **last** one is the **maximum**. The **current** value is **colorful**.\n**Gray** values are the **minimum** and the **maximum** values before.\n\n![](https://raw.githubusercontent.com/d8corp/perfocode/main/3.png)\n\nYou can modify `index.js` to change performance of getter.\n```javascript\nconst {perfocode, describe, test} = require('perfocode')\n\nperfocode('output-file', () =\u003e {\n  describe('getters vs methods', () =\u003e {\n    class GetterVsMethod {\n      constructor () {\n        this._value = 0\n      }\n      get value () {\n        for (let i = 0; i \u003c 1000;) {\n          i++\n        }\n        return this._value\n      }\n      getValue () {\n        return this._value\n      }\n    }\n\n    const getterVsMethod = new GetterVsMethod()\n\n    test('getter', () =\u003e getterVsMethod.value)\n    test('method', () =\u003e getterVsMethod.getValue())\n  })\n})\n```\nRun the file and you see big changes in performance.\n\n![](https://raw.githubusercontent.com/d8corp/perfocode/main/4.png)\n\nAlso, it works if you have big improvements.\n\n![](https://raw.githubusercontent.com/d8corp/perfocode/main/5.png)\n \nYou can run `describe` and `test` anywhere.\n\nYou can change testing timeout by 3rd argument of `perfocode`, `describe` and `test`\n```javascript\ntest('empty', () =\u003e {}, 1000)\n```\n## Issues\nIf you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/perfocode/issues)  \n[![issues](https://img.shields.io/github/issues-raw/d8corp/perfocode)](https://github.com/d8corp/perfocode/issues)  \n\u003e ---\n[![stars](https://img.shields.io/github/stars/d8corp/perfocode?style=social)](https://github.com/d8corp/perfocode/stargazers)\n[![watchers](https://img.shields.io/github/watchers/d8corp/perfocode?style=social)](https://github.com/d8corp/perfocode/watchers)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd8corp%2Fperfocode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fd8corp%2Fperfocode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fd8corp%2Fperfocode/lists"}