{"id":31447393,"url":"https://github.com/peinan/swpy","last_synced_at":"2025-10-01T01:42:04.765Z","repository":{"id":57472787,"uuid":"185938334","full_name":"peinan/swpy","owner":"peinan","description":"A simple, yet useful stopwatch library","archived":false,"fork":false,"pushed_at":"2022-12-08T05:40:16.000Z","size":111,"stargazers_count":6,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-24T15:48:49.374Z","etag":null,"topics":["pip","poetry","pypi","python","python3","stopwatch","stopwatch-library","timer"],"latest_commit_sha":null,"homepage":"","language":"Python","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/peinan.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":"2019-05-10T07:16:09.000Z","updated_at":"2024-03-05T07:14:01.000Z","dependencies_parsed_at":"2023-01-24T14:31:00.215Z","dependency_job_id":null,"html_url":"https://github.com/peinan/swpy","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/peinan/swpy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peinan%2Fswpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peinan%2Fswpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peinan%2Fswpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peinan%2Fswpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peinan","download_url":"https://codeload.github.com/peinan/swpy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peinan%2Fswpy/sbom","scorecard":{"id":726678,"data":{"date":"2025-08-11","repo":{"name":"github.com/peinan/swpy","commit":"262515d410bddaa3da72721ae2c11cfda1e2ee37"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/9 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":"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":"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":-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":"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":"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":"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":"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 '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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 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"}},{"name":"Vulnerabilities","score":0,"reason":"16 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2022-42986 / GHSA-43fp-rhv2-5gv8","Warn: Project is vulnerable to: PYSEC-2023-135 / GHSA-xqr8-7jwr-rhp7","Warn: Project is vulnerable to: PYSEC-2022-238 / GHSA-h3qr-fjhm-jphw","Warn: Project is vulnerable to: PYSEC-2024-60 / GHSA-jjg7-2v4v-x38h","Warn: Project is vulnerable to: PYSEC-2020-92 / GHSA-hj5v-574p-mj7c","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: GHSA-9hjg-9r4m-mvj7","Warn: Project is vulnerable to: GHSA-9wx4-h78v-vm56","Warn: Project is vulnerable to: PYSEC-2023-74 / GHSA-j8r2-6x86-q33q","Warn: Project is vulnerable to: GHSA-34jh-p97f-mpxf","Warn: Project is vulnerable to: PYSEC-2023-212 / GHSA-g4mx-q9vg-27p4","Warn: Project is vulnerable to: GHSA-pq67-6m6q-mj2v","Warn: Project is vulnerable to: PYSEC-2023-192 / GHSA-v845-jxx5-vc9f","Warn: Project is vulnerable to: PYSEC-2020-148 / GHSA-wqvq-5m8c-6g24","Warn: Project is vulnerable to: PYSEC-2021-108","Warn: Project is vulnerable to: PYSEC-2024-187 / GHSA-rqc4-2hc7-8c8v"],"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-22T13:01:11.233Z","repository_id":57472787,"created_at":"2025-08-22T13:01:11.233Z","updated_at":"2025-08-22T13:01:11.233Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277782747,"owners_count":25876207,"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-09-30T02:00:09.208Z","response_time":75,"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":["pip","poetry","pypi","python","python3","stopwatch","stopwatch-library","timer"],"created_at":"2025-10-01T01:42:02.314Z","updated_at":"2025-10-01T01:42:04.760Z","avatar_url":"https://github.com/peinan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swpy: A simple, yet useful stopwatch library for python\n\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/swpy.svg?logo=python\u0026logoColor=white\u0026style=flat-square)](https://pypi.org/project/swpy/)\n[![PyPI](https://img.shields.io/pypi/v/swpy.svg?style=flat-square)](https://pypi.org/project/swpy/)\n[![CircleCI](https://img.shields.io/circleci/project/github/peinan/swpy.svg?logo=circleci\u0026style=flat-square)](https://circleci.com/gh/peinan/swpy/tree/master)\n[![codecov](https://img.shields.io/codecov/c/gh/peinan/swpy.svg?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/peinan/swpy)\n[![PyPI - License](https://img.shields.io/pypi/l/swpy.svg?color=blue\u0026style=flat-square)](https://github.com/peinan/swpy/blob/master/LICENSE)\n\n## Requirements\n\n- Python 3.6+\n\n## Install\n\nJust use pip to install.\n\n```bash\npip install swpy\n```\n\n## Usage\n\n### Basic Usage\n\nImport `Timer` class from `swpy`, and use `with` statement to capsule the block where you want timing.\n\n```python\nfrom swpy import Timer\nfrom time import sleep\n\nwith Timer():\n    sleep(1)\n```\n\nOr use `start()` and `stop()` function to controll the timer.\n\n```python\nt = Timer()\nt.start()\nsleep(1)\nt.stop()\n```\n\nAnd the output will look like below:\n\n```\n[timer-1557406243.3309178] started.\n[timer-1557406243.3309178] finish time: 1.00 sec.\n```\n\n### Features\n\n#### Name the timer\n\nYou can name the timer to make it easy to recognize.\n\n```python\nwith Timer(name='test timer'):\n    sleep(1)\n```\n\nNow the timer is renamed to `test timer` !\n\n```\n[test timer] started.\n[test timer] finish time: 1.00 sec.\n```\n\n#### Lap time and Split time\n\nThere are two types to measuring time without stoping: lap time and split time. The figure below may help you to understand the differences.\n\n![split_lap_time](https://github.com/peinan/swpy/blob/master/imgs/split_lap_time.png)\n\nWe prepared `split` and `lap` functions for this kind of usage. The examples are below.\n\n```python\n# measure split time\nwith Timer('timer') as t:\n    sleep(1)\n    t.split()\n    sleep(1)\n    t.split()\n    sleep(1)\n    t.split()\n```\n\n```\n# outptus\n[timer] started.\n[timer] split time:  1.00 sec.\n[timer] split time:  2.01 sec.\n[timer] split time:  3.01 sec.\n[timer] finish time: 3.01 sec.\n```\n\n```python\n# measure lap time\nwith Timer('timer') as t:\n    sleep(1)\n    t.lap()\n    sleep(1)\n    t.lap()\n    sleep(1)\n    t.lap()\n```\n\n```\n# outputs\n[timer] started.\n[timer] lap time:    1.00 sec.\n[timer] lap time:    1.01 sec.\n[timer] lap time:    1.00 sec.\n[timer] finish time: 3.01 sec.\n```\n\nAnd you can name your lap/split time in the case of measuring several tasks in a single run as below.\n\n```python\nwith Timer('task timer') as t:\n    task1()\n    t.lap('task1')\n    task2()\n    t.lap('task2')\n```\n\n```\n# outputs\n[task timer] started.\n[task timer] [task1] lap time:    3.69 sec.\n[task timer] [task2] lap time:    4.21 sec.\n[task timer] finish time: 7.91 sec.\n```\n\n#### Use your own logger\n\nYou can use your own logger instead of the default `print`.\n\n```python\nfrom logzero import logger\nimport logging\n\nwith Timer(name='test timer', logger=logger, level=logging.DEBUG):\n    sleep(1)\n```\n\nIt will output using logger.\n\n```\n[D 190510 14:41:59 swpy:15] [test timer] started.\n[D 190510 14:42:00 swpy:15] [test timer] finish time: 1.01 sec.\n```\n\n#### Define your own callback\n\nSometimes, we want to do something after the job has done like notifying the result to slack, executing the next process and so on. Callback feature will help you to do those.\n\n```python\n# define a slack notification function\nimport requests, json\ndef send_slack(msg):\n    requests.post(SLACK_URL, json.dumps({'text': msg}))\n\n# just specify the callback argument\nwith Timer(name='experiment-1', callback=send_slack):\n    sleep(1)\n```\n\n## License\n\n[MIT](https://github.com/peinan/swpy/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeinan%2Fswpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeinan%2Fswpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeinan%2Fswpy/lists"}