{"id":21615831,"url":"https://github.com/valango/timewaste","last_synced_at":"2026-04-25T11:36:16.618Z","repository":{"id":57377207,"uuid":"292869951","full_name":"valango/timewaste","owner":"valango","description":"Lightweight multi-threading capable execution time analyzer / profiler","archived":false,"fork":false,"pushed_at":"2020-10-01T21:07:56.000Z","size":378,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"development","last_synced_at":"2025-09-21T13:33:59.889Z","etag":null,"topics":["backend","browser","execution","frontend","leaks","multi-threading","nodejs","profiler"],"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/valango.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-09-04T14:34:15.000Z","updated_at":"2020-10-01T21:07:58.000Z","dependencies_parsed_at":"2022-09-26T16:41:45.083Z","dependency_job_id":null,"html_url":"https://github.com/valango/timewaste","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/valango/timewaste","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Ftimewaste","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Ftimewaste/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Ftimewaste/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Ftimewaste/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valango","download_url":"https://codeload.github.com/valango/timewaste/tar.gz/refs/heads/development","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valango%2Ftimewaste/sbom","scorecard":{"id":914882,"data":{"date":"2025-08-11","repo":{"name":"github.com/valango/timewaste","commit":"f097a552a035abe1b0c94a5982ee2e1f5ff940aa"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"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":"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":"Code-Review","score":0,"reason":"Found 0/30 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":"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":"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":"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":"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":"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 'development'","Warn: branch protection not enabled for branch 'master'"],"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"}},{"name":"Vulnerabilities","score":0,"reason":"30 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T20:36:24.182Z","repository_id":57377207,"created_at":"2025-08-24T20:36:24.182Z","updated_at":"2025-08-24T20:36:24.182Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32261117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"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":["backend","browser","execution","frontend","leaks","multi-threading","nodejs","profiler"],"created_at":"2024-11-24T22:12:57.184Z","updated_at":"2026-04-25T11:36:11.594Z","avatar_url":"https://github.com/valango.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# timewaste\n[![Build Status](https://travis-ci.org/valango/timewaste.svg?branch=master)](https://travis-ci.org/valango/timewaste) \n[![Code coverage](https://img.shields.io/codecov/c/gh/valango/timewaste?label=codecov\u0026logo=codecov)](https://codecov.io/gh/valango/timewaste)\n\nLightweight multi-threading capable execution time analyzer / profiler.\n\nThis package:\n   1. provides clean and focused reports immune to code bundling / optimization;\n   1. reports execution statistics of any code sequences, not just functions;\n   1. can handle concurrent threads / server endpoints;\n   1. can handle callback-based code, like express.js middleware;\n   1. monitors execution consistency by reporting \"return leaks\";\n   1. in case of nested calls, both aggregated and self time can be reported;\n   1. supports both _Node.js_ and browser environments;\n   1. allows performance monitoring and reporting to be controlled/analyzed programmatically.\n\n**Note:**\nNode.js [built-in profiler](https://nodejs.org/en/docs/guides/simple-profiling/),\nas well as Developer Tools of many browsers\nmay provide all you need without installing anything - so please check those out\nif you haven't done so.\n\n## Install\n```shell script\n   yarn add timewaste       # Either so...\n   npm i -S timewaste       # or so.\n```\n\n## Usage\nIn order to do something, timewaste needs you to _waste some time\non **spicing** your code_ with its API calls, mostly (_`profBeg`_ and _`profEnd`_).\n\nHere's an example:\n```javascript\nimport {profBeg, profEnd, profTexts} from 'timewaste'\n\nfunction a() {\n  const h = profBeg('a')\n  //  Do something and sometimes call b().\n  profEnd(h)\n}\n\nfunction b () {\n  const h = profBeg('b')\n  //  Do something.\n  profEnd(h)\n}\n\nfor (let i = 0; i \u003c 1000; ++i) a()\n\nconsole.log(profTexts())\n```\n\nWill produce an output similar to:\n```\n*** LEAKS (1):\ntag                                                   count\n-----------------------------------------------------------\na b c d e f                                             766\na b c d e f g h i j k l m n o p                       10000\n\nRESULTS:\ntag   count     avg     time   total_avg   total_time\n-----------------------------------------------------\ne     10000   16.20   162036       16.20       162036\no     10000    9.89    98884        9.89        98884\n . . .\nf       234    4.00        4      936.00          936\nj     10000    0.42     4203       14.03       140277\np         0    0.00        0        0.00            0\n```\n\nThis tells us that code sequence **`e`**, although gobbling up a gargantuan chunk\nof execution time, might not be the main culprit, because some of it's sub-parts or\nfunctions called, did the most.\n\nAlso, there have been some problem with function **`f`** which sometimes (not always,\nas _count_ is not _`0`_) has terminated\n(by throwing exception, returning or yielding a thread) without calling `profEnd()` first.\nWhen it comes to **`p`** then it has never terminated as appropriate.\n\nThe leaks are most likely caused by missing something when spicing the target code,\nand not by target code bugs as such.\n\n## API\n### Constants\n**`P_TAG P_TIME P_AVG P_TOTAL P_TOT_AVG P_COUNT P_THREADS`**\nnumeric indexes of _measures record_ columns, also applicable to\n[_sortByField_](#results) and [_fieldMask_](#texts) arguments.\n\n**`P_NONE`** special value to prevent any sorting (mostly used internally).\n\n**`P_HEADERS`** string array containing headers for `profTexts()` function.\n\n### Functions\nIn the text below, the [jsdoc `{...}`](https://jsdoc.app/tags-type.html)\nsyntax is used sparingly;\n`[type]` means that argument is optional or value may be _`undefined`_.\n\n**`profBeg`**`(tag: string, threadId: [*]) : {number | boolean | undefined}`\n\nCreates a call entry for the main or secondary thread.\nReturns _numeric handle_ on success, _`false`_ on failure and\n_`undefined`_ when profiler disabled.\n\n**`profEnd`**`(handle: number, threadId: [*]) : {boolean | undefined}`\n\nCloses an entry created by `profBeg()`.\nReturns _true_ on success, _`false`_ on failure and\n_`undefined`_ when profiler disabled.\n\n**`profEnable`**`(yes=) : {boolean | undefined}`\n\nQuery and possibly switch profiler _enabled_ status, which is initially _true_.\nWhile _false_, the `profBeg()` and `profEnd()` functions do nothing and return `false`.\nCalling `profEnable(false)` while there are call pending will be ignored, and internal error\nwill be registered and `undefined` returned;\nsee [`profStatus()`](#status) for details.\n\u003cbr /\u003eProfiling can be switched off and back on using this function.\n\n\u003ca name=\"results\"\u003e**`profResults`**`(sortByField: [number], earlierResults: [Object]) : Object`\u003c/a\u003e\n\nCloses any pending measure entries, then\ncomputes and returns array of measurement result objects, possibly combined with\n`earlierResults`.\nUnless _`sortByField`_ is -1, measures fill be sorted according to its value, which\nshould be one of exported _`F_...`_ constants; default is _`F_AVG`_.\nThe returned object has properties:\n   * `[errors]: Array\u003cError\u003e`,\n   * `[leaks]: Array\u003c[path, count]\u003e` - cases when `profBeg` was called but `profEnd` was not.\n   * `measures: Array\u003c[]\u003e` - profiling results sorted by `sortByField`.\n\n**`profSetup`**`(options:Object=) : Object`\n\nQuery and possibly change profiler general options, which can be:\n   * `getTime: {function():*}` - function for querying current timestamp;\n   * `hook: {function():*}` - callback to be called before registering an internal error;\n   * `timeScale: {number|bigint}` - must be the same type as `getTime()` return value;\n   * `precision: {number=3}` - positions after decimal point, used by `profText()`;\n   \nIn _Node.js_ environment, `getTime` defaults to `microtime`, in browser environment to\n`Date.now`; `timeScale` to `BigInt(1e3)` (microseconds) or `1` (milliseconds), respectively.\n\nCalling this function with an argument _will **reset all** internal data structures_.\nDoing so repeatedly may significantly slow down the code.\n\n\u003ca name=\"status\"\u003e**`profStatus`**`(details : boolean=) : Object`\u003c/a\u003e\n\nQuery for general status of profiling engine. The returned object has the following properties:\n   * `callDepth: number` - number of open synchronous entries;\n   * `enabled: boolean` - internal flag controllable via `profEnable()`;\n   * `errorCount: number`;\n   * `leakCount: number`;\n   * `threadCount: number`;\n   \nWith `details` truey, the following extra properties will be available, too:\n   * `errors: Error[]` - errors caused by bad API calls;\n   * `openCalls: string[]` - currently open call stack as array of tags;\n   * `openThreads: string[]` - list of currently running threads as `'tag\u003eid'`.\n   \n\u003ca name=\"texts\"\u003e**`profText`**`(sortByField: [number], data: [Object], fieldMask: [number[]]) : string[]`\u003c/a\u003e\n\nTurns `data` into line-by-line text array representing a pretty-printable table.\nIf `data` are omitted, then calls `profResults()` is called to get one.\n\nThe `sortByField` argument here is analogous to the one of `profResults()` function.\n\nWhen present, the `fieldMask` leaves on only the fields mentioned or excludes\nfields with negative index, e.g. like in `profTexts([-P_TOTAL, -P_TIME])`. It is not\npossible to exclude the _tag field_.\n\n## In-depth\n\n### Environment control\nIn **_production mode_** (e.g. `process.env.NODE_ENV === 'production'`),\nthe profiler code gets never loaded, and a do-nothing API will be exported instead.\nSo, no noticeable computational overhead nor extra code will be added.\n\nTo enable `timewaste` even in production build, set `TIMEWASTE` environment variable _true_.\n\n### Error handling\nCode failures and improper use of `timewaste` may result in errors.\nExceptions get thrown on bad calls (e.g. invalid argument type or format).\nOther failures, like mismatched `profBeg/profEnd` pairs, will be silently accumulated\nin internal collections\navailable via `profStatus().errors`, resettable via `profStatus()`.\n\n### Multi-threading\nWhen profiling code with actual multi-threading (like when using web workers) or\njust asynchronously executed code (like Node.js web server end points), it is likely\n(_`profBegin()`_,  _`profEnd()`_) call pairs get un-matched, effectively disabling\nthe profiler.\n\n## Developer notes\n\nEvery feedback and assistance will be appreciated. Use github issues list first,\nand feel free to make pull request of _**development** branch_ in order to contribute.\n\nThere is some documentation about its inner parts available in _`src/*.md`_ files.\n\n### Instrumental scripts in `package.json`\n\n   * **`clean`**: erase all temporary files but not installed dependencies,\n   * **`lint`**: ...sure,\n   * **`purge`**: erase everything, expect stuff kept in _VCS_,\n   * **`speeds`**: speed benchmark,\n   * **`test`**: module tests,\n   * **`test:coverage`**: \"codecov\",\n   * **`test1`**: e.g.: `yarn test1 numbers` to check for failures w/o generating coverage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalango%2Ftimewaste","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalango%2Ftimewaste","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalango%2Ftimewaste/lists"}