{"id":21509060,"url":"https://github.com/dmitrytarassov/performance-framework","last_synced_at":"2025-06-16T13:02:09.026Z","repository":{"id":251258608,"uuid":"836853603","full_name":"dmitrytarassov/performance-framework","owner":"dmitrytarassov","description":"Performance Framework","archived":false,"fork":false,"pushed_at":"2024-08-01T19:52:40.000Z","size":13,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-24T01:07:51.532Z","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/dmitrytarassov.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-01T17:36:43.000Z","updated_at":"2024-08-01T19:52:43.000Z","dependencies_parsed_at":"2024-08-01T20:56:45.096Z","dependency_job_id":"33024a5a-8223-47f1-9aa3-d8578d43ed5f","html_url":"https://github.com/dmitrytarassov/performance-framework","commit_stats":null,"previous_names":["dmitrytarassov/performance-framework"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitrytarassov%2Fperformance-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitrytarassov%2Fperformance-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitrytarassov%2Fperformance-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmitrytarassov%2Fperformance-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmitrytarassov","download_url":"https://codeload.github.com/dmitrytarassov/performance-framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056424,"owners_count":20390719,"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-11-23T21:17:18.935Z","updated_at":"2025-03-17T15:14:32.336Z","avatar_url":"https://github.com/dmitrytarassov.png","language":"JavaScript","readme":"# JS Performance Testing Framework\n\nThis framework facilitates performance testing for JavaScript code. Each test is located in a separate directory and follows a specific structure using macros to define preparation, execution, and cleanup code blocks.\n\n## Directory Structure\n\nEach test should be placed in its own directory. Inside the directory, you should have `.js` files that contain the following macros:\n\n- `// @prepare` - Code to prepare the test.\n- `// @end-prepare` - End of preparation code.\n- `// @run` - Code for the test execution.\n- `// @end-run` - End of execution code.\n- `// @clear` - Code to clean up after each run.\n- `// @end-clear` - End of cleanup code.\n\n### Example\n\nA test file might look like this:\n\n```javascript\n// @prepare\nconst dataArray = [...Array(+process.env.DATA_ARRAY_LENGTH)].map((e, index) =\u003e index);\nlet result = 0;\n// @end-prepare\n\n// @run\nfor (const el of dataArray) {\n    result += el;\n}\n// @end-run\n\n// @clear\nresult = 0;\n// @end-clear\n```\n\n## Running a Test\nTo run a test, use the following command:\n\n```sh\nyarn test DIRECTORY_NAME\n```\nReplace DIRECTORY_NAME with the name of the directory containing your test files.\n\n## How It Works\n- The script will collect the content of each macro and insert it into a template.\n- The generated test file will look like this:\n\n```javascript\nconst maxRunsCount = 100_000;\n\nlet RUNS_COUNT = +process.env.RUNS_COUNT || maxRunsCount;\n\nif (RUNS_COUNT \u003e maxRunsCount) {\n    RUNS_COUNT = maxRunsCount;\n}\n\n(() =\u003e {\n    // @prepare\n    const dataArray = [...Array(+process.env.DATA_ARRAY_LENGTH)].map((e, index) =\u003e index);\n    let result = 0;\n\n    for (let i = 0; i \u003c 100_000; i++) {\n        // @run\n        for (const el of dataArray) {\n            result += el;\n        }\n\n        // @clear\n        result = 0;\n    }\n})();\n```\n\nAfter assembling the script, it will execute each generated file using /usr/bin/time.\n\n## Environment Variables\n- `RUNS_COUNT` - The number of times each test will be executed (maximum of 100,000).\n- `DATA_ARRAY_LENGTH` - The length of the array used in the test.\n\n## Example Usage\n\n- Create a directory for your test, for example, myTest.\n\n- Inside the myTest directory, create a file named 1-test.js with the following content:\n\n```javascript\n// @prepare\nconst dataArray = [...Array(+process.env.DATA_ARRAY_LENGTH)].map((e, index) =\u003e index);\nlet result = 0;\n// @end-prepare\n\n// @run\nfor (const el of dataArray) {\n    result += el;\n}\n// @end-run\n\n// @clear\nresult = 0;\n// @end-clear\n```\n- Inside the myTest directory, create second file named 2-test.js with the following content:\n\n```javascript\n// @prepare\nconst dataArray = [...Array(+process.env.DATA_ARRAY_LENGTH)].map((e, index) =\u003e index);\nlet result = 0;\n// @end-prepare\n\n// @run\nfor (let i = 0; i \u003c dataArray.length; i++) {\n    result += dataArray[i];\n}\n// @end-run\n\n// @clear\nresult = 0;\n// @end-clear\n```\n\n- Run the test using the following command:\n\n```sh\nyarn test myTest\n```\n\nThe framework will handle the assembly and execution of the test, providing performance metrics for analysis.\n\n## Requirements\n- Node.js\n- Yarn\n- \nEnsure you have the necessary environment variables set before running your tests to customize the execution based on your requirements.\n\n## License\nThis project is licensed under the MIT License.\n\nFor any questions or contributions, feel free to open an issue or submit a pull request.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitrytarassov%2Fperformance-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmitrytarassov%2Fperformance-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmitrytarassov%2Fperformance-framework/lists"}