{"id":17059166,"url":"https://github.com/flit/elapsedtimer","last_synced_at":"2026-05-05T02:31:52.457Z","repository":{"id":24113744,"uuid":"27501871","full_name":"flit/elapsedtimer","owner":"flit","description":"Python elapsed time utilities","archived":false,"fork":false,"pushed_at":"2022-04-01T15:33:16.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T21:42:56.285Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flit.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":"2014-12-03T18:41:16.000Z","updated_at":"2022-05-07T14:44:42.000Z","dependencies_parsed_at":"2022-08-06T01:01:03.281Z","dependency_job_id":null,"html_url":"https://github.com/flit/elapsedtimer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flit%2Felapsedtimer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flit%2Felapsedtimer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flit%2Felapsedtimer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flit%2Felapsedtimer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flit","download_url":"https://codeload.github.com/flit/elapsedtimer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245068727,"owners_count":20555812,"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":[],"created_at":"2024-10-14T10:32:56.068Z","updated_at":"2026-05-05T02:31:47.398Z","avatar_url":"https://github.com/flit.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"elapsedtimer\n============\n\nPython elapsed time utilities.\n\nThe main interface to this package is an `ElapsedTimer` class. This class will use the highest\nresolution timer available to Python depending on the OS, either `time.time()` or\n`time.clock()`. Its purpose is easily to measure and print the duration of a task, and is\nnormally meant to be used as a context manager.\n\nBasic example:\n\n    \u003e\u003e\u003e with ElapsedTimer('say hello'):\n    ...     print 'hi there!'\n    hi there!\n    13.113 µs: say hello\n\nElapsedTimer\n------------\n\nThe constructor for `ElapsedTimer` takes an optional string describing the operation being\nperformed. It also optionally accepts a file object to change where the resulting duration\nmessage will be printed. The output file defaults to sys.stdout.\n\nThe constructor can also take a logger instance and log level via the optional `logger` and\n`loglevel` keyword parameters. If a logger is provided, it takes precedence over a file object\nand the duration message will be output via the logger. The log level defaults to `DEBUG`.\n\nYou can control an `ElapsedTimer` instance directly instead of using it as a context manager.\nIt has `start()` and `stop()` methods. The `stop()` method will not print the duration for\nyou like exiting a context manager instance does.\n\nThere is an `elapsed` property that returns the elapsed time since `start()` was called or the\ncontext manager entered. A `timedelta` property is also available that returns the elapsed\ntime as a datetime.timedelta object instead of a float, though note that this class this only has\nmicrosecond resolution.\n\nThere is a module-level `enable` variable that acts as a global enable switch for all printing\nof results by `ElapsedTimer`. It defaults to True.\n\nTimeout\n-------\n\nAnother class in the module is `Timeout`. It adds a few methods to make it easy to check for\ntimeouts. You can use this class as a context manager. The constructor takes the same parameters\nas for `ElapsedTimer`, except for a new first param of the timeout in seconds.\n\nThere are two methods to check the timeout, `check()` and `check_and_raise()`. The former\ncompares the elapsed time against the timeout and returned True if a timeout occurred. The latter\nwill raise `TimeoutError` if a timeout happens. You can use the `timed_out` property to\nas another way to check, equivalent to calling `check()`.\n\n\nLicense\n-------\n\nThis package is licensed under the BSD three-clause license. See the LICENSE file for details.\n\nCopyright © 2014-2022 Chris Reed.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflit%2Felapsedtimer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflit%2Felapsedtimer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflit%2Felapsedtimer/lists"}