{"id":20839292,"url":"https://github.com/ailln/torbjorn","last_synced_at":"2025-05-08T21:41:37.256Z","repository":{"id":57476455,"uuid":"206981790","full_name":"Ailln/torbjorn","owner":"Ailln","description":"🔨提供一些实用的 Python 装饰器","archived":false,"fork":false,"pushed_at":"2022-07-09T15:39:26.000Z","size":18,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-31T05:48:32.863Z","etag":null,"topics":["decorators","python-decorators","python-library","python-package","python-tools"],"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/Ailln.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-09-07T14:45:22.000Z","updated_at":"2024-02-20T07:57:08.000Z","dependencies_parsed_at":"2022-09-12T15:22:25.393Z","dependency_job_id":null,"html_url":"https://github.com/Ailln/torbjorn","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":"Ailln/python-package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ailln%2Ftorbjorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ailln%2Ftorbjorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ailln%2Ftorbjorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ailln%2Ftorbjorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ailln","download_url":"https://codeload.github.com/Ailln/torbjorn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225110502,"owners_count":17422412,"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":["decorators","python-decorators","python-library","python-package","python-tools"],"created_at":"2024-11-18T01:13:12.881Z","updated_at":"2024-11-18T01:13:13.538Z","avatar_url":"https://github.com/Ailln.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Torbjorn\n\n[![Pypi](https://img.shields.io/pypi/v/torbjorn.svg)](https://pypi.org/project/torbjorn/)\n[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/Ailln/torbjorn/blob/master/LICENSE)\n[![stars](https://img.shields.io/github/stars/Ailln/torbjorn.svg)](https://github.com/Ailln/torbjorn/stargazers)\n[![build](https://img.shields.io/github/workflow/status/Ailln/torbjorn/build)](https://github.com/Ailln/torbjorn/actions?query=workflow%3Abuild)\n\n🔨 提供一些实用的 Python 装饰器～\n\n`Torbjorn`（即托比昂）是守望先锋游戏中的英雄之一，他拥有一个强力输出的炮台。\n俗话说「他强任他强，我用托比昂」，我希望本项目也能给你的 Python 代码提供强力的支持！\n\n\u003e 🎈️ v0.1.1：\n\u003e\n\u003e 使用 `time.perf_counter` 计算时间，以提高精准度。\n\n## 安装\n\n```bash\n# pip 安装\npip install torbjorn\n\n# or 源码安装\ngit clone https://github.com/Ailln/torbjorn.git\ncd torbjorn \u0026\u0026 python setup.py install\n```\n\n## 使用\n\n- `run_time`: 计算运行时间\n- `run_count`: 计算运行次数\n- `ctrl_c`: 程序终止验证\n\n```python\nimport logging\n\nimport torbjorn as tbn\n\n\nlogger = logging.getLogger(__name__)\n\n\n@tbn.run_time\n@tbn.run_time(name=\"test_time\")\n@tbn.run_time(logger=logger, name=\"test_time\")\n@tbn.run_count\n@tbn.run_count(name=\"test_count\")\n@tbn.run_count(logger=logger, name=\"test_count\")\n@tbn.ctrl_c\ndef calculate_million_numbers(num):\n    number = 0\n    for _ in range(num):\n        number += 1\n\n\nif __name__ == '__main__':\n    for _ in range(10):\n        calculate_million_numbers(1000000)\n        \n# output:\n# [calculate_million_numbers] run count(t): 1\n# [test_count] run count(t): 1\n# [test_count] run count(t): 1\n# [test_time] run time(s): 0.074010\n# [test_time] run time(s): 0.074463\n# [calculate_million_numbers] run time(s): 0.074512\n# [calculate_million_numbers] run count(t): 2\n# [test_count] run count(t): 2\n# [test_count] run count(t): 2\n# [test_time] run time(s): 0.074386\n# [test_time] run time(s): 0.074522\n# [calculate_million_numbers] run time(s): 0.074556\n# ^CAre you sure to quit? (yes|y) / (no|n)\n# \u003e\u003e 123\n# ^CAre you sure to quit? (yes|y) / (no|n)\n# \u003e\u003e no\n# [calculate_million_numbers] run count(t): 3\n# [test_count] run count(t): 3\n# [test_count] run count(t): 3\n# [test_time] run time(s): 0.072722\n# [test_time] run time(s): 0.072863\n# [calculate_million_numbers] run time(s): 0.072897\n# ^CAre you sure to quit? (yes|y) / (no|n)\n# \u003e\u003e yes\n# \u003e\u003e exit...\n```\n\n## 许可\n\n[![](https://award.dovolopor.com?lt=License\u0026rt=MIT\u0026rbc=green)](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failln%2Ftorbjorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Failln%2Ftorbjorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failln%2Ftorbjorn/lists"}