{"id":31619545,"url":"https://github.com/jasonray/statman-stopwatch","last_synced_at":"2025-10-30T21:13:16.081Z","repository":{"id":23908392,"uuid":"27288489","full_name":"jasonray/statman-stopwatch","owner":"jasonray","description":"Simple high res stopwatch for node.js","archived":false,"fork":false,"pushed_at":"2024-06-10T02:46:51.000Z","size":383,"stargazers_count":17,"open_issues_count":7,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-27T09:25:35.844Z","etag":null,"topics":["metrics","metrics-gathering","stopwatch","timing"],"latest_commit_sha":null,"homepage":"https://statman-stopwatch.jayray.net/","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/jasonray.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":"2014-11-29T02:09:02.000Z","updated_at":"2025-08-05T05:27:42.000Z","dependencies_parsed_at":"2024-03-13T23:25:53.542Z","dependency_job_id":"62faab57-9087-450c-b0a2-75bf2ea7939f","html_url":"https://github.com/jasonray/statman-stopwatch","commit_stats":{"total_commits":292,"total_committers":7,"mean_commits":"41.714285714285715","dds":"0.17465753424657537","last_synced_commit":"a3d9b80bfab8d00db801196396b232552fae557e"},"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"purl":"pkg:github/jasonray/statman-stopwatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonray%2Fstatman-stopwatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonray%2Fstatman-stopwatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonray%2Fstatman-stopwatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonray%2Fstatman-stopwatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jasonray","download_url":"https://codeload.github.com/jasonray/statman-stopwatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jasonray%2Fstatman-stopwatch/sbom","scorecard":{"id":507562,"data":{"date":"2025-08-11","repo":{"name":"github.com/jasonray/statman-stopwatch","commit":"0cb27102c14839e884904a55eddf28a4ce226322"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.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":"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":10,"reason":"no dangerous workflow patterns detected","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":"Code-Review","score":0,"reason":"Found 1/19 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/node.js.yml:1","Warn: no topLevel permission defined: .github/workflows/npm-publish.yml:1","Info: no jobLevel write permissions found"],"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":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/node.js.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/node.js.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/npm-publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/npm-publish.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/jasonray/statman-stopwatch/npm-publish.yml/master?enable=pin","Info:   0 out of   6 GitHub-owned GitHubAction dependencies pinned","Info:   3 out of   3 npmCommand dependencies pinned"],"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 22 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T23:38:07.303Z","repository_id":23908392,"created_at":"2025-08-19T23:38:07.303Z","updated_at":"2025-08-19T23:38:07.303Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278621844,"owners_count":26017253,"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","status":"online","status_checked_at":"2025-10-06T02:00:05.630Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["metrics","metrics-gathering","stopwatch","timing"],"created_at":"2025-10-06T14:07:37.090Z","updated_at":"2025-10-06T14:07:39.697Z","avatar_url":"https://github.com/jasonray.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# statman-stopwatch \n\n[![Node.js CI](https://github.com/jasonray/statman-stopwatch/actions/workflows/node.js.yml/badge.svg)](https://github.com/jasonray/statman-stopwatch/actions/workflows/node.js.yml) [![on npm](http://img.shields.io/npm/v/statman-stopwatch.svg?style=flat)](https://www.npmjs.org/package/statman-stopwatch) [![Known Vulnerabilities](https://snyk.io/test/github/jasonray/statman-stopwatch/badge.svg)](https://snyk.io/test/github/jasonray/statman-stopwatch) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/1afa7995fa5c4f7ba94d06d2a8fb3086)](https://app.codacy.com/gh/jasonray/statman-stopwatch/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n\n`statman-stopwatch` is one of the metrics from the [`statman`](https://github.com/jasonray/statman) library.  It is a simple high res stopwatch for node.js.  Stopwatch is useful for determining the amount of time it takes to perform an activity.\n\nFor example, you may want to determine how long certain potentially expensive activities take in your code (such as calling to an external web services or fetching a dataset from a database).  Few lines of code will let you capture that info.  There are much more elegant solutions - this is a simple roll-your-own approach.\n\nNew Features:\n{: .label .label-purple }\n* 2.17.1: specify units when reading stopwatch\n\n## Install it!\n### Option 1: access directly (recommended)\nInstall using npm:\n``` bash\nnpm install statman-stopwatch\n```\n\nReference in your app:\n``` javascript\nconst Stopwatch = require('statman-stopwatch');\nconst stopwatch = new Stopwatch();\n```\n\n### Option 2: access from `statman` (deprecated)\nInstall using npm:\n``` bash\nnpm install statman\n```\n\nReference in your app:\n``` javascript\nconst statman = require('statman');\nconst stopwatch = new statman.Stopwatch();\n```\n\n## Use it!\n### Constructor\n-   `Stopwatch()` =\u003e create instance of a stopwatch\n-   `Stopwatch(true)` =\u003e create instance of stopwatch, and have it autostart\n-   `Stopwatch(name, autostart, delta)` =\u003e create instance of stopwatch, with name, specify if to autostart, and supply an automatic delta (see setStartTimeDelta)\n\n### start\n-   `start()` =\u003e starts the stopwatch, let the timing begin!\n\n### read\n-   `read(precision, units)` =\u003e reads the stopwatch to determine how much time has elapsed.  Note that the stopwatch continues to run.  Returns the time elapsed in milliseconds.\n    -   If `precision` is provided, `read()` will round to the number of decimals places based on precision.  \n    -   By default, `read` returns in `ms`.  If `units` is specified to `s`, will return values in seconds.\n    \n-   `time(precision)` =\u003e alias for `read()`\n\n### stop, suspend\n-   `stop()` =\u003e stops the stopwatch, and returns the time elapsed in milliseconds\n\n### restart\n-   `restart()` =\u003e performs a `stop()` and `start()`\n\n### split\n-   `split()` =\u003e temp stops the stopwatch, allow read() to return time based on when split occurs.  Use `unsplit()` to resume the stopwatch\n\n### unsplit\n-   `unsplit()` =\u003e use follow a `split()` to resume the stopwatch\n\n### splitTime\n-   `splitTime` =\u003e while the stopwatch is split, returns the time as of the split\n\n### reset\n-   `reset()` =\u003e restores the stopwatch back to init state and clears start and stop times\n\n### setStartTimeDelta\n-   `setStartTimeDelta(number)` =\u003e provide an elapsed time (in milliseconds) at which to start the stopwatch\n\n### resume\n-   `resume` =\u003e used in conjunction with `suspend` to pause/restart the stopwatch\n\n### Example\n\nThere are some examples in `example/example.js`\n\n#### Basic usage\nCreate a new stopwatch, `start()` it, and later `read()` it\n``` javascript\n    const Stopwatch = require('statman-stopwatch');\n    const sw = new Stopwatch();\n    sw.start();\n\n    // do some activity\n\n    const delta = sw.read();\n ```\n\n#### Autostart\n`start()` is too hard.  Create a new stopwatch with autostart=true, and later `read()` it\n``` javascript\n    const Stopwatch = require('statman-stopwatch');\n    const sw = new Stopwatch(true);\n\n    // do some activity\n\n    const delta = sw.read();\n ```\n\n#### Stop\nCreate a new stopwatch, `stop()` it, and later `read()` it\n``` javascript\n    const Stopwatch = require('statman-stopwatch');\n    const sw = new Stopwatch(true);\n\n    // do some activity\n\n    sw.stop();\n\n    // do some more activity\n\n    //returns time associated with when stop() occurred\n    const delta = sw.read();\n ```\n\n#### Delta\nThere may be scenarios in which you need to add multiple timings together.  To help with this, you can initialize the stopwatch with a value that will be added to the readings.\nNote that most scenarios could also be achieved by suspending/resuming the stopwatch.\nCreate a new stopwatch, `start()` it, and later `read()` it\n``` javascript\n    const Stopwatch = require('statman-stopwatch');\n    const sw = new Stopwatch();\n    sw.setStartTimeDelta(5000);\n    sw.start();\n\n    // do some activity which takes 500\n\n    const delta = sw.read();\n    // delta will be 5500 (the initial 5000ms set in setStartTimeDelta plus the elapsed 500ms)\n ```\n\n#### Suspend/Resume\nThere are times where you may want to exclude certain events from the stopwatch, so you can `suspend` (pause) the stopwatch, then `resume` after the excluded event is complete.\nCreate a new stopwatch, `start()` it, and later `read()` it\n``` javascript\n    const Stopwatch = require('statman-stopwatch');\n    const sw = new Stopwatch();\n    sw.start();\n\n    // do some activity\n\n\n    sw.suspend();\n    //do some activity that should not be included in the timings\n    sw.resume();\n\n    let delta = sw.stop();\n ```\n \n## Build it!\n-   Make sure that you have `node` and `npm` installed\n-   Clone source code to you local machine\n-   Setup dependencies: `npm install`\n-   run tests: `npm test`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonray%2Fstatman-stopwatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasonray%2Fstatman-stopwatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasonray%2Fstatman-stopwatch/lists"}