{"id":23170062,"url":"https://github.com/abhinavomprakash/pretty-timeit","last_synced_at":"2026-03-08T05:33:20.386Z","repository":{"id":51090940,"uuid":"368538254","full_name":"AbhinavOmprakash/pretty-timeit","owner":"AbhinavOmprakash","description":"Pretty timeit.","archived":false,"fork":false,"pushed_at":"2021-07-16T17:18:04.000Z","size":69,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-16T05:00:06.957Z","etag":null,"topics":["python","timeit","timer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AbhinavOmprakash.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":"2021-05-18T13:22:21.000Z","updated_at":"2024-10-10T17:44:19.000Z","dependencies_parsed_at":"2022-08-02T15:46:02.494Z","dependency_job_id":null,"html_url":"https://github.com/AbhinavOmprakash/pretty-timeit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AbhinavOmprakash/pretty-timeit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbhinavOmprakash%2Fpretty-timeit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbhinavOmprakash%2Fpretty-timeit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbhinavOmprakash%2Fpretty-timeit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbhinavOmprakash%2Fpretty-timeit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbhinavOmprakash","download_url":"https://codeload.github.com/AbhinavOmprakash/pretty-timeit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbhinavOmprakash%2Fpretty-timeit/sbom","scorecard":{"id":7948,"data":{"date":"2025-08-11","repo":{"name":"github.com/AbhinavOmprakash/pretty-timeit","commit":"32339b7bd30a842c5394d5191583dc6fc8248cca"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/28 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":"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":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:26: update your workflow using https://app.stepsecurity.io/secureworkflow/AbhinavOmprakash/pretty-timeit/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:27: update your workflow using https://app.stepsecurity.io/secureworkflow/AbhinavOmprakash/pretty-timeit/main.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/AbhinavOmprakash/pretty-timeit/main.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/main.yml:34","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand 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":"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":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" 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":"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":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v0.1.0 not signed: https://api.github.com/repos/AbhinavOmprakash/pretty-timeit/releases/43501138","Warn: release artifact v0.1.0 does not have provenance: https://api.github.com/repos/AbhinavOmprakash/pretty-timeit/releases/43501138"],"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"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2024-48 / GHSA-fj7x-q9j7-g6q6","Warn: Project is vulnerable to: PYSEC-2022-42969","Warn: Project is vulnerable to: GHSA-jfmj-5v4g-7637"],"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 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"}}]},"last_synced_at":"2025-08-14T13:58:36.230Z","repository_id":51090940,"created_at":"2025-08-14T13:58:36.231Z","updated_at":"2025-08-14T13:58:36.231Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270961491,"owners_count":24675914,"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-08-18T02:00:08.743Z","response_time":89,"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":["python","timeit","timer"],"created_at":"2024-12-18T03:25:40.416Z","updated_at":"2026-03-08T05:33:15.328Z","avatar_url":"https://github.com/AbhinavOmprakash.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ptimeit\n[![codecov](https://codecov.io/gh/AbhinavOmprakash/pretty-timeit/branch/main/graph/badge.svg?token=QCRpIcv84o)](https://codecov.io/gh/AbhinavOmprakash/pretty-timeit)\n\n***timeit, but with a decorator interface.***   \n\n## Why did I write this?\ntimeit is a great module, but whenever I wanted to use it, I had to look up the syntax, and even after that it was tricky to get things working. I wanted something that had the similar functionality of timeit but an easier, more intuitive syntax.   \nUnder the hood, I take the same approach as timeit does-\n- Everything is imported once.\n- The garbage collector is disabled when the function is run.\n- By default the function runs 1 milllion times.\n\n## Installation\n\nWith pip.\n\n```Bash\n$ pip install pretty-timeit\n```\n\nWith poetry.\n\n```Bash\n$ poetry add pretty-timeit\n```\n\n## Usage.\n\n### A simple example.\n\n```Python\nfrom ptimeit import timethis, Timer\n\n# although this is a decorator, your original function will not be modified.\n@timethis() \ndef function_to_be_timed():\n    lst = [i for i in range(10)]\n\nTimer.run() # Call this at the end of the file.\n```\n\noutput\n```Console\nname                 | Execution time\nfunction_to_be_timed | 0.5608107\n```\nNote: By default `Timer.run()` Prints the results to the console. \nIf you want it to return a string, do this.\n\n```Python\nTimer.run(print_results=False) # returns a string\n```\n\n\n### Mixing positional arguments with keyword arguments.\nPositional Arguments must be passed inside a list even if there is one argument.  \nKeyword arguments must be passed inside a dictionary.   \nNote the order follows the common idiom of `function(*args, **kwargs)`.\n\n```Python\n@timethis( [10], {\"second_count_up_to\":10} )\ndef function_to_be_timed(count_up_to, second_count_up_to=100):\n    lst = [i for i in range(count_up_to)]\n    lst2 = [i for i in range(second_count_up_to)]\n\nTimer.run()\n```\n\n### Adding custom descriptive names to your functions\nIf you want to see a different name other than the function name in the final report you can pass that to the decorator using `name=\"\"` argument.\n```Python\n@timethis([10], name=\"A list comprehension that counts up to 10\")\ndef function_to_be_timed(count_up_to):\n    lst = [i for i in range(count_up_to)]\nTimer.run()\n```\n\n```Console\nname                                      | Execution time\nA list comprehension that counts up to 10 | 0.5393135\n``` \n\n### Changing the number of times the function is repeated.\nBy default, like timeit, The function is repeated 1 million times,\nbut this can be changed by passing a `repeat=` to `Timer.run()` like this.\n\n```Python\nTimer.run(repeat=100) #The function to be timed will loop for hundred times.\n```\n\n### Comparing multiple functions.\nA common use case that I have found for the timeit module, is to compare\nthe runtime speed of two different algorithms, this is very easy to do in p-timeit.\n\n```Python\n@timethis(100, name=\"using a for loop\")\ndef my_func(count_up_to):\n    lst=[]\n    for i in range( count_up_to): \n        lst.append(i)\n\n@timethis(100, name=\"using a List comprehension\")\ndef my_func_2(count_up_to):\n    lst = [i for i in range(count_up_to)]\n\nTimer.run(compare=True)\n```\nOutput\n```console\nrank | name                       | Execution time\n1    | using a List comprehension | 2.3460704000000003\n2    | using a for loop           | 4.37266\n```\nAs you can see the list comprehension is faster than using a for loop.\n\nNote: you can compare as many functions as you like. Not just two.\nThe `compare=True` flag formats the output, And orders the results from The fastest functions to the slowest.\nYou can still run multiple functions with `Timer.run()`.\n\nHere's an example without compare\n\n```python\n@timethis([10], name=\"using a for loop\")\ndef my_func(count_up_to):\n    lst=[]\n    for i in range( count_up_to): \n        lst.append(i)\n\n@timethis([10], name=\"using a List comprehension\")\ndef my_func_2(count_up_to):\n    lst = [i for i in range(count_up_to)]\n\n@timethis([10], name=\"using two lists\")\ndef my_func_3(count_up_to):\n    lst = [i for i in range(count_up_to)]\n    lst2 = [i for i in range(count_up_to)]\n\nTimer.run()\n```\noutput\n```Console\nname                       | Execution time\nusing a for loop           | 0.7021932000000001\nusing a List comprehension | 0.6186622999999999\nusing two lists            | 1.0627897000000002\n```\nNotice that the functions are ordered as they were defined\nand not by execution time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinavomprakash%2Fpretty-timeit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhinavomprakash%2Fpretty-timeit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhinavomprakash%2Fpretty-timeit/lists"}