{"id":13658361,"url":"https://github.com/icebob/benchmarkify","last_synced_at":"2025-07-31T11:40:58.733Z","repository":{"id":74759039,"uuid":"80557833","full_name":"icebob/benchmarkify","owner":"icebob","description":":zap: Benchmark framework for NodeJS","archived":false,"fork":false,"pushed_at":"2023-09-01T20:01:10.000Z","size":138,"stargazers_count":47,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T20:45:16.577Z","etag":null,"topics":["benchmark","benchmark-framework","benchmarking"],"latest_commit_sha":null,"homepage":"","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/icebob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-01-31T20:13:08.000Z","updated_at":"2025-02-19T15:29:06.000Z","dependencies_parsed_at":"2023-11-15T06:46:07.440Z","dependency_job_id":null,"html_url":"https://github.com/icebob/benchmarkify","commit_stats":{"total_commits":62,"total_committers":2,"mean_commits":31.0,"dds":"0.016129032258064502","last_synced_commit":"6099a50389b3117870a4c40541af0008a3f29447"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icebob%2Fbenchmarkify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icebob%2Fbenchmarkify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icebob%2Fbenchmarkify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icebob%2Fbenchmarkify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icebob","download_url":"https://codeload.github.com/icebob/benchmarkify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794558,"owners_count":21162614,"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":["benchmark","benchmark-framework","benchmarking"],"created_at":"2024-08-02T05:00:59.019Z","updated_at":"2025-04-14T07:08:30.680Z","avatar_url":"https://github.com/icebob.png","language":"JavaScript","readme":"# :zap: benchmarkify\r\nBenchmark framework for Node.js for measure the execution time of JS codes. It can generate JSON result, chart image or draw a simple bar chart to the console.\r\n\r\n# Installation\r\n```\r\n$ npm i benchmarkify\r\n```\r\n\r\n# Usage\r\n\r\n**Example benchmark suite**\r\n```js\r\nconst Benchmarkify = require(\"benchmarkify\");\r\n\r\n// Create a new benchmark\r\n// The `.printHeader` method will print the name of benchmark \u0026 some\r\n// information from the OS/PC to the console.\r\nconst benchmark = new Benchmarkify(\"Simple example\", { description: \"This is a common benchmark\", chartImage: true }).printHeader();\r\n\r\n// Create a test suite\r\nbenchmark.createSuite(\"String concatenate\", { time: 1000, description: \"Concatenate string in different ways\" })\r\n\r\n    .add(\"Concat with '+'\", () =\u003e {\r\n\t\tlet s = \"\";\r\n\t\tfor (let i = 0; i \u003c 1000; i++)\r\n\t\t\ts += \"test\" + i;\r\n\t\treturn s;\r\n\t})\r\n\r\n\t.ref(\"Concat with array \u0026 join\", () =\u003e {\r\n\t\tlet s = [];\r\n\t\tfor (let i = 0; i \u003c 1000; i++)\r\n\t\t\ts.push(\"test\" + i);\r\n\t\treturn s.join();\r\n\t});\r\n\r\nbenchmark.run();\r\n```\r\n\r\n**Output**\r\n```\r\n==================\r\n  Simple example\r\n==================\r\n\r\nPlatform info:\r\n==============\r\n   Windows_NT 10.0.19045 x64\r\n   Node.JS: 18.16.0\r\n   V8: 10.2.154.26-node.26\r\n   CPU: 13th Gen Intel(R) Core(TM) i5-13500 × 20\r\n   Memory: 32 GB\r\n\r\nSuite: String concatenate\r\n=========================\r\n\r\n√ Concat with '+'                105 533 ops/sec\r\n√ Concat with array \u0026 join        57 987 ops/sec\r\n\r\n   Concat with '+'                +81,99%    (105 533 ops/sec)   (avg: 9μs)\r\n   Concat with array \u0026 join (#)        0%     (57 987 ops/sec)   (avg: 17μs)\r\n\r\n┌──────────────────────────┬────────────────────────────────────────────────────┐\r\n│ Concat with '+'          │ ██████████████████████████████████████████████████ │\r\n├──────────────────────────┼────────────────────────────────────────────────────┤\r\n│ Concat with array \u0026 join │ ███████████████████████████                        │\r\n└──────────────────────────┴────────────────────────────────────────────────────┘\r\n\r\nChart: https://image-charts.com/chart.js/2.8.0?bkg=white\u0026c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22Concat%20with%20%27%2B%27%22%2C%22Concat%20with%20array%20%26%20join%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Dataset%201%22%2C%22backgroundColor%22%3A%22rgba%2854%2C%20162%2C%20235%2C%200.5%29%22%2C%22borderColor%22%3A%22rgb%2854%2C%20162%2C%20235%29%22%2C%22borderWidth%22%3A1%2C%22data%22%3A%5B105532.65917212216%2C57986.883366982394%5D%7D%5D%7D%2C%22options%22%3A%7B%22responsive%22%3Afalse%2C%22legend%22%3A%7B%22display%22%3Afalse%2C%22position%22%3A%22top%22%7D%2C%22title%22%3A%7B%22display%22%3Atrue%2C%22text%22%3A%22String%20concatenate%7C%28ops%2Fsec%29%22%7D%2C%22layout%22%3A%7B%22padding%22%3A20%7D%7D%7D\r\n-----------------------------------------------------------------------\r\n```\r\n\r\n**Example chart image**\r\n![Example chart image](https://image-charts.com/chart.js/2.8.0?bkg=white\u0026c=%7B%22type%22%3A%22bar%22%2C%22data%22%3A%7B%22labels%22%3A%5B%22Concat%20with%20%27%2B%27%22%2C%22Concat%20with%20array%20%26%20join%22%5D%2C%22datasets%22%3A%5B%7B%22label%22%3A%22Dataset%201%22%2C%22backgroundColor%22%3A%22rgba%2854%2C%20162%2C%20235%2C%200.5%29%22%2C%22borderColor%22%3A%22rgb%2854%2C%20162%2C%20235%29%22%2C%22borderWidth%22%3A1%2C%22data%22%3A%5B105320.73392654078%2C57369.423976363796%5D%7D%5D%7D%2C%22options%22%3A%7B%22responsive%22%3Afalse%2C%22legend%22%3A%7B%22display%22%3Afalse%2C%22position%22%3A%22top%22%7D%2C%22title%22%3A%7B%22display%22%3Atrue%2C%22text%22%3A%22String%20concatenate%7C%28ops%2Fsec%29%22%7D%2C%22layout%22%3A%7B%22padding%22%3A20%7D%7D%7D)\r\n\r\n**JSON result**\r\n\r\nIf you need the results in JSON use `.then` after `run()`\r\n\r\n```js\r\nbenchmark.run().then(res =\u003e console.log(res));\r\n```\r\n\r\n**Result on the console:**\r\n```js\r\n{\r\n  name: 'Simple example',\r\n  description: 'This is a common benchmark',\r\n  meta: {},\r\n  suites: [\r\n    {\r\n      name: 'String concatenate',\r\n      description: 'Concatenate string in different ways',\r\n      meta: {},\r\n      unit: 'ops/sec',\r\n      tests: [\r\n        {\r\n          name: \"Concat with '+'\",\r\n          meta: {},\r\n          unit: 'ops/sec',\r\n          fastest: true,\r\n          stat: {\r\n            duration: 1.0064495,\r\n            cycle: 106,\r\n            count: 106000,\r\n            avg: 0.000009494806603773585,\r\n            rps: 105320.73392654078,\r\n            percent: 83.58339098878338\r\n          }\r\n        },\r\n        {\r\n          name: 'Concat with array \u0026 join',\r\n          meta: {},\r\n          unit: 'ops/sec',\r\n          reference: true,\r\n          stat: {\r\n            duration: 1.0109915,\r\n            cycle: 58,\r\n            count: 58000,\r\n            avg: 0.000017430887931034482,\r\n            rps: 57369.423976363796,\r\n            percent: 0\r\n          }\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  timestamp: 1693594301782,\r\n  generated: 'Fri Sep 01 2023 20:51:41 GMT+0200 (közép-európai nyári idő)',\r\n  elapsedMs: 2466\r\n}\r\n```\r\n\r\n# API\r\n\r\n## Class Benchmarkify\r\n\r\n```js\r\nconst benchmark = new Benchmarkify(\"Benchmark #1\", opts);\r\n```\r\n\r\n### Constructor options\r\n* `logger` - print messages to this logger. Default: `console`\r\n* `spinner` - show spinner when running tests. Default: `true`\r\n* `minSamples` - Minimum samples. Default: `0` - not used\r\n* `description` - Custom description field.\r\n* `meta` - To store any meta information. Result JSON contains it.\r\n* `chartImage` - Generate chart image url and print to the console after every suite.\r\n* `drawChart` - Draw a bar chart to the console after every suite. Default: `true`\r\n\r\n### Methods\r\n* `createSuite` - Create a new benchmark suite.\r\n* `run(suites: Array): Promise` - \r\n\r\n## Class Suite\r\n\r\n```js\r\nconst bench1 = benchmark.createSuite(\"Date performance\", { time: 1000 });\r\n```\r\n\r\n### Constructor options\r\n* `name` - Name of suite.\r\n* `time` - Time of test. Default: `5000` (5sec)\r\n* `minSamples` - Minimum samples. Default `0` - disabled\r\n* `description` - Custom description field.\r\n* `unit` - Measurement unit. Default: `\"ops/sec\"`.\r\n* `meta` - To store any meta information. Result JSON contains it.\r\n\r\n### Methods\r\n* `add(name: string, fn: Function, opts: Object)` - Add a function to the suite\r\n* `skip(name: string, fn: Function, opts: Object)` - Skip the function\r\n* `only(name: string, fn: Function, opts: Object)` - Run only this function\r\n* `ref(name: string, fn: Function, opts: Object)` - Add a function and it'll be the reference\r\n* `run(): Promise` - Run the suite.\r\n* `setup(fn): Promise` - Function to execute before test suite.\r\n* `tearDown(fn): Promise` - Function to execute after test suite.\r\n\r\n### Async functions\r\nIf you would like to test async function use the `done` callback.\r\n\r\n```js\r\nbench.add(\"Async call test\", done =\u003e {\r\n    asyncFunction(data).then(() =\u003e done());\r\n});\r\n```\r\n\r\nor \r\n\r\n```js\r\nbench.add(\"Async call test\", async done =\u003e {\r\n    await asyncFunction(data)\r\n    done();\r\n});\r\n```\r\n\r\n# License\r\nBenchmarkify is available under the [MIT license](https://tldrlegal.com/license/mit-license).\r\n\r\n# Contact\r\n\r\nCopyright (C) 2023 Icebob\r\n\r\n[![@icebob](https://img.shields.io/badge/github-icebob-green.svg)](https://github.com/icebob) [![@icebob](https://img.shields.io/badge/twitter-Icebobcsi-blue.svg)](https://twitter.com/Icebobcsi)\r\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficebob%2Fbenchmarkify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficebob%2Fbenchmarkify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficebob%2Fbenchmarkify/lists"}