{"id":15578314,"url":"https://github.com/fsvieira/perfmetrics","last_synced_at":"2026-04-16T01:33:19.062Z","repository":{"id":57135827,"uuid":"320012789","full_name":"fsvieira/perfmetrics","owner":"fsvieira","description":"Get performance metrics of js classes/functions with simple metrics reports.","archived":false,"fork":false,"pushed_at":"2020-12-15T22:57:47.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-28T22:46:32.227Z","etag":null,"topics":["js","metrics","optimization","perf","time"],"latest_commit_sha":null,"homepage":"https://fsvieira.github.io/perfmetrics/","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/fsvieira.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}},"created_at":"2020-12-09T16:20:43.000Z","updated_at":"2020-12-15T22:57:49.000Z","dependencies_parsed_at":"2022-09-02T09:25:16.676Z","dependency_job_id":null,"html_url":"https://github.com/fsvieira/perfmetrics","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fsvieira/perfmetrics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsvieira%2Fperfmetrics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsvieira%2Fperfmetrics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsvieira%2Fperfmetrics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsvieira%2Fperfmetrics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fsvieira","download_url":"https://codeload.github.com/fsvieira/perfmetrics/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fsvieira%2Fperfmetrics/sbom","scorecard":{"id":412898,"data":{"date":"2025-08-11","repo":{"name":"github.com/fsvieira/perfmetrics","commit":"7492611dc98a15dbd41006696cbe6906716b14c4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-18T23:09:16.739Z","repository_id":57135827,"created_at":"2025-08-18T23:09:16.739Z","updated_at":"2025-08-18T23:09:16.739Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31867711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-15T15:24:51.572Z","status":"ssl_error","status_checked_at":"2026-04-15T15:24:39.138Z","response_time":63,"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":["js","metrics","optimization","perf","time"],"created_at":"2024-10-02T19:08:24.430Z","updated_at":"2026-04-16T01:33:19.041Z","avatar_url":"https://github.com/fsvieira.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Perf Metrics\nGet performance metrics of js classes/functions with simple metrics reports.\n\n# How to use\n\nFirst you will need to install the lib to get some metrics:\n\n```\n  npm install @perfmetrics/lib\n```\n\nNext just call the lib from your code:\n\n```javascript\nconst perfMetrics = require(\"@perfmetrics/lib\");\n```\n\nThe perfMetrics is a function that takes two arguments:\n  * target: class, function, object, anything that can be used with proxy. \n  * log, a callback (by default = console.log)  with the arguments: (name, start, end, duration) =\u003e ... \n     * name: the name of function, or ClassName.NameFunc\n     * start: start time (higth resolution time in milliseconds)\n     * end: end time (higth resolution time in milliseconds)\n     * duraction: time that takes to execute the function (higth resolution time in milliseconds)\n  \n  \n  \nNow lets track a function:\n\n```javascript\nconst perfMetrics = require(\"@perfmetrics/lib\");\n\nfunction quadraticTime(n) { // n^2\n    let r = [];\n    for (let i = 0; i \u003c n; i++) {\n        for (let j = 0; j \u003c n; j++) {\n            r.push([i, j]);\n        }\n    }\n}\n\nconst quadraticTimePerf = perfMetrics(quadraticTime);\n\n// Now when you call quadraticTimePerf will track all the execution time\n// In this case it will be logged to console.log\n\nfor (let i = 0; i \u003c 100; i++) {\n  quadraticTimePerf(1000 + i);\n}\n\n```\n\nIts easy to implement a new logger, but we can use the filestats logger, just install \n\n```\nnpm install @perfmetrics/filestats\n```\n\nThen we can change the code to use the logger like this:\n\n```javascript\nconst perfMetrics = require(\"@perfmetrics/lib\");\n\nfunction quadraticTime(n) { // n^2\n    let r = [];\n    for (let i = 0; i \u003c n; i++) {\n        for (let j = 0; j \u003c n; j++) {\n            r.push([i, j]);\n        }\n    }\n}\n\n// Output, save file every 1 second\nconst fsLogger = fileStats(\"./stats.log\", 1000);\nconst quadraticTimePerf = perfMetrics(quadraticTime, fsLogger);\n\n// Now when you call quadraticTimePerf will track all the execution time\n// In this case it will be logged to console.log\n\nfor (let i = 0; i \u003c 100; i++) {\n  quadraticTimePerf(1000 + i);\n}\n\n```\n\nAfther running the code we will get a stats.log file. To generate a report we first install package:\n\n```\nnpm install @perfmetrics/cli --global\n```\n\nAnd finally just run:\n\n```\nperfmetrics -s stats.log --html stats\n```\nThis will generate a stats.html report like this one: https://fsvieira.github.io/perfmetrics/\n\nTo get more information on how to use the cli, just run \n\n```\nperfmetrics -h\n```\n\nFor more information check out the examples on the examples folder of this repo.\n\n\n## How it works ?\n\nUsing a proxy perfMetrics will try to keep track of the execution time of all functions generated from the proxy funcion/class, the time statistics and \nfunction information is logged using a callback function on perfMetrics, currently there in this package there is only a file logger.\n\nUsing reporter like `node reports/html.js stats.log stats` will create a stats.html report. \n\n### Complexity calculation\n\nThe complexity is calculated using regressions functions (https://github.com/Tom-Alexander/regression-js) on the collected data. \nIt goes like this:\n\n  * Order the duraction data ascending,\n  * Run multiple methods and choose the 2 (if they exist) with the best r-square score.\n\nThis means that more data will give better results. It also means that a function may not correspond to code classification but that can be a good thing, \nwhy spending time otimizing functions that never reach the worst case in real cenario usage.\n\n## Notes\n\nThis is still a work in progress, but alredy a working beta. \n\nWhat I would like to do in the future:\n  * Add and improve loggers: using webworker compatible api, rest-api. \n  * Add more reports, including a live webapp using a rest-api server.\n  * Compare two reports of same funcitions so that we can understand if there is improvements.\n  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsvieira%2Fperfmetrics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffsvieira%2Fperfmetrics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffsvieira%2Fperfmetrics/lists"}