Saravanan666/pypi-org huggingface dataset:
Package: timer
TimerPython code timer, support block wise and function wiseInstallationpipinstalltimerUsageimportfromtimerimporttimerdecorate without brackets@timerdeffunc():...decorate with brackets@timer()deffunc():...decorate with name and time unit@timer('function name','s')deffunc():...decorate with key word arguments@timer(name='function name',unit='s')deffunc():...block wise without objectwithtimer():...block wise with objectwithtimer()ast:...print(t.elapse)Sample Codeimportloggingimporttimefromtimerimporttimer,get_timer# default timer's logging level is logging.DEBUG# so timer would print nothing if logging level is logging.INFO or higherlogging.basicConfig(level=logging.DEBUG)# or you can change default timer's logging leveltimer.set_level(logging.DEBUG)# also you can get a timer with custom logging level with get_timer(level)warning_timer=get_timer(logging.WARNING)# explicit the timer's name and it's time unit@timer('function:add',unit='s')defadd(a,b):time.sleep(.1)returna+b# function name is timer's name for default@timerdefsub(a,b):time.sleep(.1)returna-bif__name__=='__main__':# 'timer' would be timer's name by defaultwithtimer('time.sleep(2)')ast:print(3)time.sleep(1)print(f'after time.sleep(1) once, t.elapse ={t.elapse}')time.sleep(1)print(f'after time.sleep(1) twice, t.elapse ={t.elapse}')print(f'after with, t.elapse ={t.elapse}')withwarning_timer('test'):passprint(add(1,1))print(sub(2,1))Outputs3
after time.sleep(1) once, t.elapse = 1.003798776
after time.sleep(1) twice, t.elapse = 2.0052743459999998
DEBUG:timer.time.sleep(2): 2.006 s
after with, t.elapse = 2.005628447
WARNING:timer.test:start
WARNING:timer.test:cost 0 ms
DEBUG:timer.function:add: 0.105 s
2
DEBUG:timer.sub: 102 ms
1Special Thanks@Krzysztof S
Package: timer2
Version:0.1.0IntroductionThetimer2module lets you schedule Python functions at specific times,
or at an interval. It can be used as a replacement tothreading.Timer,
the difference is thattimer2is always only using a single thread (unless
you manually start more of them)You should never use this to apply expensive operations, as this would not
be effective when running in a single thread, rather you should make the
timer move the operations to a execution pool (like a thread/multiprocessing
pool, or maybe sending a message):>>> pool = multiprocessing.Pool()
>>> timer2.apply_after(10000, pool.apply_async, (expensive_fun, ))DocumentationTimer is using Sphinx, and the latest documentation is available at GitHub:http://ask.github.com/timer2InstallationYou can installtimer2either via the Python Package Index (PyPI)
or from source.To install usingpip,:$ pip install timer2To install usingeasy_install,:$ easy_install timer2If you have downloaded a source tarball you can install it
by doing the following,:$ python setup.py build
# python setup.py install # as rootExamplesApply function afternmsecs:>>> import timer2
>>> timer2.apply_after(msecs, fun, args, kwargs, priority=0)Apply function everynmsecs:>>> timer2.apply_interval(msecs, fun, args, kwargs, priority=0)Apply function at a specific date (adatetimeobject):>>> timer2.apply_at(datetime, fun, args, kwargs, priority=0)Cancelling timersTheapply_*functions returns atimer2.Entryinstance,
you can use this to cancel the execution:>>> tref = timer2.apply_after(msecs, fun, args, kwargs)
>>> tref.cancel()Running customTimerthreadsWhen using the module interface a default timer thread is started
as soon as you schedule something. If you want to keep track of the
thread manually, you can use thetimer2.Timerclass:>>> timer = timer2.Timer()
>>> timer.apply_after(msecs, fun, args, kwargs)
>>> timer.stop() # stops the thread and joins it.Bug trackerIf you have any suggestions, bug reports or annoyances please report them
to our issue tracker athttp://github.com/ask/timer2/issues/ContributingDevelopment oftimer2happens at Github:http://github.com/ask/timer2You are highly encouraged to participate in the development. If you don’t
like Github (for some reason) you’re welcome to send regular patches.LicenseThis software is licensed under theNew BSD License. See theLICENSEfile in the top distribution directory for the full license text.
Package: timer3
Version:0.1.0IntroductionThetimer3module lets you schedule Python functions at specific times,
or at an interval. It can be used as a replacement tothreading.Timer,
the difference is thattimer3is always only using a single thread (unless
you manually start more of them)You should never use this to apply expensive operations, as this would not
be effective when running in a single thread, rather you should make the
timer move the operations to a execution pool (like a thread/multiprocessing
pool, or maybe sending a message):>>> pool = multiprocessing.Pool()
>>> timer3.apply_after(10000, pool.apply_async, (expensive_fun, ))InstallationYou can installtimer3either via the Python Package Index (PyPI)
or from source.To install usingpip,:$ pip install timer3ExamplesApply function afternmsecs:>>> import timer3
>>> timer3.apply_after(msecs, fun, args, kwargs, priority=0)Apply function everynmsecs:>>> timer3.apply_interval(msecs, fun, args, kwargs, priority=0)Apply function at a specific date (adatetimeobject):>>> timer3.apply_at(datetime, fun, args, kwargs, priority=0)Cancelling timersTheapply_*functions returns atimer3.Entryinstance,
you can use this to cancel the execution:>>> tref = timer3.apply_after(msecs, fun, args, kwargs)
>>> tref.cancel()Running customTimerthreadsWhen using the module interface a default timer thread is started
as soon as you schedule something. If you want to keep track of the
thread manually, you can use thetimer3.Timerclass:>>> timer = timer3.Timer()
>>> timer.apply_after(msecs, fun, args, kwargs)
>>> timer.stop() # stops the thread and joins it.LicenseThis software is licensed under theNew BSD License. See theLICENSEfile in the top distribution directory for the full license text.
Package: timer4
timertimeris a library to time your Python code.Installationpipinstalltimer4# not timerUsagetimeruseswithstatement to watch how long your code running:importtimefromtimerimportTimerwithTimer().watch_and_report(msg='test'):# running code that do lots of computationtime.sleep(1.0)# when the code reach this part, it will output the message and the time it tooks.# for example:#     test: 10.291 secondsIf you don't want to report the result immediately, use thewatchmethod instead. Whenever you've done, callreport.importtimefromtimerimportTimer# you can either create a timer variable first, or use Timer.get_instance()# that will return a singleton variable.total=0foriteminrange(7):# only measure the part that we wantwithTimer.get_instance().watch("sum of square"):total+=item**2time.sleep(0.2)# doing other things that we don't want to measuretime.sleep(0.8)Timer.get_instance().report()You can also use different way to print the message, such as using logging by passing a printing function to the report method:report(print_fn=logger.info)You can also choose to append the result to a filereport(append_to_file='/tmp/runtime.csv'). This is useful if you want to measure runtime of your method and put it to a file to plot it later.
Package: timeranges
timerangesTime ranges.Read the DocsInstallationpiptimerangesis available onpip:pipinstalltimerangesGitHubYou can also install the latest version of the code directly from GitHub:pipinstallgit+git://github.com/MicaelJarniac/timerangesUsageFor more examples, see thefull documentation.TimeRangefromdatetimeimporttimefromtimerangesimportTimeRange# Create a `TimeRange` instance with the interval "0:00 -> 10:00"time_range=TimeRange(time(0),time(10))# Check if these times are contained in `time_range`asserttime(0)intime_rangeasserttime(5)intime_rangeasserttime(10)intime_range# Check if these times aren't contained in `time_range`asserttime(10,0,1)notintime_rangeasserttime(11)notintime_rangeasserttime(20)notintime_rangeTimeRangesfromdatetimeimporttimefromtimerangesimportTimeRange,TimeRanges# Create some `TimeRange` instancestime_range_1=TimeRange(time(0),time(10))time_range_2=TimeRange(time(15),time(20))# Create a `TimeRanges` instance containing multiple `TimeRange`time_ranges=TimeRanges([time_range,time_range_2])asserttime(0)intime_rangesasserttime(5)intime_rangesasserttime(10)intime_rangesasserttime(12)notintime_rangesasserttime(15)intime_rangesasserttime(17)intime_rangesasserttime(20)intime_rangesasserttime(22)notintime_rangesWeekRangefromdatetimeimporttime,datetimefromtimematic.enumsimportWeekdayfromtimerangesimportTimeRange,TimeRanges,WeekRangeweek_range=WeekRange({Weekday.MONDAY:TimeRanges([TimeRange(time(5),time(10)),TimeRange(time(12),time(14)),]),Weekday.SATURDAY:TimeRanges([TimeRange(time(0),time(2)),TimeRange(time(4),time(8)),]),})assertdatetime(2021,12,6,5,0,0)inweek_rangeassertdatetime(2021,12,6,8,0,0)inweek_rangeassertdatetime(2021,12,6,10,0,0)inweek_rangeassertdatetime(2021,12,6,11,0,0)notinweek_rangeassertdatetime(2021,12,7,5,0,0)notinweek_rangeassertdatetime(2021,12,13,5,0,0)inweek_rangeContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.More details can be found inCONTRIBUTING.Contributors ✨Micael Jarniac🐛💻📖💡🤔🚧📆👀🔧⚠️LicenseMITCreated fromcookiecutter-python-project.
Package: timer-cli
Timer-CLIA very simple Python CLI tool to start a countdown timer.InstallationEasily install timer-cli using pip:pipinstalltimer-cliUsage$timer[options]durationHow to specify a durationSyntax for a duration is__h__m__swhere the hour, minute and second values are all optional.Duration examples2mins 30secs -2m30s10hrs 5secs -10h5s1hr 25mins 45secs -1h25m45sOptions--no-bellSupplying the--no-bellflag will stop the terminal from "ringing the bell" (making a sound) once the timer has finished.-m, --messageUse this flag to specify a message to display under the timer. Make sure to surround your string with quotation marks.$timer1h30m-m"Review the pull requests"ContributingContributions are always welcome!If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull RequestLicenseThis code is distributed under theApache-2.0license. SeeLICENSEfor more information.
Package: timer-dict
TimerDictThis package provides a simple dictionary-like class, which drops items after a
set amount of time.fromdatetimeimporttimedeltafromtypingimportUnion# When creating a TimerDict specify for how long items should live for:my_dict=TimerDict(default_duration=timedelta(minutes=5))# Then add items like you would to any dictionarymy_dict["foo"]="bar"# Or use the `put` method if you want to explicitly set the duration for a keymy_dict.put('foo','bar',timedelta(seconds=10))# Getting items also works just like you'd would expectprint(my_dict['foo'])Implementation DetailsInternally, the dict keeps a queue of all items and when they should be removed.
The items are then purged whenever control flow passes to the dictionary, such
as when adding or getting an item. There is no separate thread orasynctask
running in the background.
Package: timerdo
A minimalist to-do list with built-in timer to keep your tasks on track.Timerdo is an intuitive CLI application that will help you focus on what really matters.RequirementsPython 3.11+No fear of the command-line interface :laughing:.Source Code:https://github.com/caiomts/timerdoDocumentation:http://caiomts.github.io/timerdo:warning: Early stage project[^2]Getting startedhttp://caiomts.github.io/timerdo/#getting-startedCLI Referencehttp://caiomts.github.io/timerdo/#CLI-ReferenceAPI Referencehttp://caiomts.github.io/timerdo/#API-ReferenceReleaseshttp://caiomts.github.io/timerdo/#Releases[^2]: Data models are mostly stable, but visualization and queries are in full development and the API can change quickly.
Package: timereporter
timereporterReport working time from the command line.RequirementsPython 3.6+, Windows/Linux/Mac.InstallationClone the repo and runpython setup.py installin the root folder.Yaml file pathThe default path of thetimereporter.yamlfile that stores the calendar data
is%USERPROFILE%\Dropbox\timereporter.yaml. To change this, set the
TIMEREPORTER_FILE environment variable to the new path, e.g.setx TIMEREPORTER_FILE "C:\mypath\timereporter.yaml"AliasIt is recommended to set an alias forpython -m timereporter, e.g. in .bashrc:alias t='python -m timereporter'The usage documentation below assumes that the above alias is set.CustomizationAfter running once, thetimereporter.yamlfile will be created. In this file, the following options can be set:Default project nameTo set another name for the default project, change thedefault_project_namevariable. The default value is EPG Program.Target hours per dayTo set the target hours per day, edit thetarget_hours_per_dayvariable. The
default value is 27900 seconds.UsageReport time on default projectt [<day> | [last | next] <weekday>] [came <time>] [left <time>] [lunch
<time>]<time>must be in one of the following formats:9,9:00,0900...Additionally, lunch times can also be in one of the following formats:45m,45 min, ...<day>must be one or more ofyesterday,monday,Tuesday, ..., oran ISO 8601 date, e.g.2017-04-01.If<day>is not set, today's date will be used.<weekday>must be one or more ofmonday,Tuesday, ...,Create a new projectt project new [--no-work] <project-name>If<project-name>is multiple words, enclose them in quotation marks, e.g."My new project".Time reported on projects tagged with--no-workreduces the required
working time for that day. This can be used e.g. for part-time parental leave.Report time on a projectt project (<project-name> | <project-number>) [<day>] <time>There is no need to spell out the entire<project-name>, a part of it is
enough.impforMy important project, for example.See also Report time on default project.Show reported timet show [last | next] week [html] [--show-weekend]
t show <month> [html] [--show-weekend]
thtmlshows the specified week in a browser windows instead of in the console.By default, Saturday and Sunday are not shown, but this can be changed by adding--show-weekend.<month>must be one ofjanuary,february, ...tis an alias fort show week.Show flex timet show flex [--from=<date>] [--to=<date>]Undo/redot (undo | redo)Show help textt (help | --help | -h)Examplest last friday came 9 left 17 lunch 45mReports a working time from 09:00 to 17:00 last Friday.t yesterday left 17:15Changes yesterday's leave time to 17:15.t project new --no-work My new projectCreates a new non-working project called My new project.t project My new project 2017-09-23 04:00Reports four hours worked on My new project the 23rd of September.t show last week htmlShows Monday-Friday of last week in the browser.t show october --show-weekendShows all days of October in the console.Running testspytest test
Package: timering
timingtimingis a Python timing library providing timer functionality.This library is one of many providing timers, but aims to:incorporate all patterns for timing execution timesof functions and code blocks in any situationwhile being minimalistic in complexity but powerful nonetheless.Some of the library's features are:It is compatible with Python 3.8+,fully typed, allowing your IDE to provide useful completions,tested usingpytestandwell documented by docstringsExample program:importtimefromtimingimportTimertimer=Timer(callback=lambdax:print(f"Took{x:.2f}seconds."))withtimer:print("Executing step 1...")time.sleep(1)withtimer:print("Executing step 2...")time.sleep(2)Output:Executing step 1...
Took 1.00 seconds.
Executing step 2...
Took 2.00 seconds.Installationtimingcan be installed using$python-mpipinstalltimeringNote that on some systems, the Python 3 executable is calledpython3instead.Release NotesSupported PatternsStart and StopCreate a timer, start and stop it:>>>fromtimingimportTimer>>>timer=Timer()>>>timer.start()>>>timer.stop()2.442877164Note thattiming.start()creates a newTimer, starts and returns it directly.ContextCreate a timer and measure the execution duration of a context:>>>withtimer:...time.sleep(1)...>>>timer.get()1.001198509Measure FunctionsCreate a timer and measure a given function:>>>importtime>>>timer.measure(lambda:time.sleep(2))>>>timer.get()2.002377642Note thattiming.measure()creates a newTimerand measures the given function with it. To retrieve the result, pass
acallbacktotiming.measure()or usetiming.prevtimer.get()if you are certain it wasn't replaced since the start
of yourtiming.measure()call.Decorator Pattern / Wrapping FunctionsCreate a timer and wrap a function to measure its execution duration:>>>timed_func=timer.wrap(lambda:time.sleep(3))>>>timed_func()>>>timer.get()3.003535439>>># alternatively>>>@timer.wrap...deftimed_func():...time.sleep(2)...>>>timed_func()>>>timer.get()2.002481228Note that there is also atiming.wrap()method available.Decorator Generator PatternTo use Python's@decoratorpattern with arguments, libraries often provide functionality for generating decorators:>>>@timer.wrap()...deftimed_func():...time.sleep(1)...>>>timed_func()>>>timer.get()1.001287624Note that there is also atiming.wrap()method available.ConfigurationTheTimerconstructor accepts aunitused for the returned results and acallbackcalled with the result everytime
the timer stops. Every method also accepts the applicable arguments to override them once.Be carefulwhen callingstop()with aunitwhen acallbackis defined as thecallbackwill be called with
the result in the new unit and not the one given to the constructor.Contributing / FeedbackI happily accept feedback and pull requests.Some ideas:Should I add support for registering multiple callbacks with different units?
Package: timer-lawn
Lawn - Low Latancy Timer Data-Structure for Large Scale SystemsTL;DR - A Lawn is a timer data store, not unlike Timer-Wheel,
but with unlimited timer span with no degradation in performance over a
large set of timerswith this API.Lawnis a high throughput data structure that is based on the
assumption that most timers are set to a small set of TTLs to boost
overall DS performance. It can assist when handling a large set of
timers with relatively small variance in TTL by effectively using minimal
queues to store timer data. Achieving O(1) for insertion and deletion of
timers, and O(1) for timer expiration.Lawns can be used for anything from keeping track of multiple real-time
TTLs of elements, to implement a straightforward dehydration system as
depicted in the article “Fast Data”.You can see the API provided by this implementation of the Lawn Data
structurehere.You can read further on the algorithm behind Lawnhere.Common Use CasesStream Coordination- Make data from one stream wait for the
corresponding data from another (preferably using sliding-window
style timing).Event Rate Limitation- Delay any event beyond current max
throughput to the next available time slot, while preserving order.Self Cleaning Claims-Check- Store data for a well known period,
without the need to search for it when it is expired or clear it from
the data-store yourself.Task Timer- Postpone actions and their respective payloads to a
specific point in time.About This ProjectThis project is based off a python version of the same concepts designed
by Adam Lev-Libfeld and developed in Tamar Labs by Adam Lev-Libfeld and
Alexander Margolin in mid-2015.A Redis module using these concepts was created by Adam Lev-Libfeld
during the RedisModulesHackathon in late 2016.This code is meant for public use and is maintained solely by Adam
Lev-Libfled.
Package: timer-module
📋 Prerequisite:Requires Python >= 3.10
TimeProfiler makes use of new features from Python's typing module.🛠️ Installation:pip install timer-module🖥️ Timer Usage:Example Usage:importtimefromtimer_moduleimportTimerModuletimer_module=TimerModule().start()timer_module.pause()time.sleep(0.2)timer_module.start()time.sleep(0.5)seconds=timer_module.get_time()print(seconds)Get the current time# SecondsTimerModule().get_time()# float# MillisecondsTimerModule().get_time_ms()# float# NanosecondsTimerModule().get_time_ns()# floatSet the starting time# SecondsTimerModule().set_time(1.0)# MillisecondsTimerModule().set_time_ms(1.0)# NanosecondsTimerModule().set_time_ns(1.0)Pause timer:TimerModule().pause()Refresh timer (preserves timer run state):TimerModule().refresh()Reset timer (resets everything)TimerModule().reset()🖥️ Profiler Usage:TimeProfiler also includes a "function_profiler" and "async_function_profiler", in a class the asynchronous methods are handled automatically, but for functions you need to select the appropriate decorator.importtimefromtimer_moduleimportTimeProfiler# You only need this line to profile the entire class# The program is run normally, this decorator will wrap# The class and its methods in order to track execution time@TimeProfiler().class_profilerclassExampleClass:def__init__(self):time.sleep(0.1)defmethod_1(self):time.sleep(0.5)self.method_2()defmethod_2(self):time.sleep(1)self.method_3()defmethod_3(self):time.sleep(1)self.method_4()defmethod_4(self):time.sleep(0.1)self.method_5()defmethod_5(self):time.sleep(0.1)ec=ExampleClass()ec.method_1()Output:
Package: timerpp
timerppfeaturesheader onlytestedno dependenciespython bindingspip3 install git+https://github.com/nbdy/timerpppip3 install timerppexamplecpp#include"timerpp.h"#include<iostream>intmain(){uint64_tlastTimestamp=TIMESTAMP_MS;uint64_tnewTimestamp=0;uint32_tx=0;timerpp::Timert([&x,&newTimestamp,&lastTimestamp]{newTimestamp=TIMESTAMP_MS;x+=newTimestamp-lastTimestamp;lastTimestamp=newTimestamp;});t.start(500);std::this_thread::sleep_for(Milliseconds(1501));t.stop();std::cout<<"1500 == "<<x<<std::endl;return0;}pythonfromtimerppimportTimerfromtimeimportsleepclassExample(Timer):elapsed_ms=0def__init__(self):Timer.__init__(self,self.callback,500)defcallback(self):self.elapsed_ms+=500e=Example()e.start()sleep(1.49)e.stop()print(f"elapsed_ms:{e.elapsed_ms}")
Package: timerpy
timerpyMeasure execution time of code sections.Installationpython3 -m pip install timerpyUsage ExamplesfromtimerpyimportTimerwithTimer():# Some code>>>TIMEELAPSED:0:00:01.199748# Specify messagewithTimer('HELLO WORLD'):# Some code>>>HELLOWORLDTIMEELAPSED:0:02:15.242731# Specify outputfromloggingimportinfo# Write to log filewithTimer('HELLO WORLD',info):# Some code>>>timer.py:INFO:stop():44:HELLOWORLDTIMEELAPSED:0:00:01.200157# Get elapsed time as float valuewithTimer()astimer1:# Some codenanoseconds=timer1.elapsed_timeprint(nanoseconds)>>>TIMEELAPSED:0:00:01.400193>>>1400192600
Package: timer.py
timer.pytimer.py provides convenient functions to measure time in Python.Installationpip install timer.pyUsagefromtimeimportsleepfromtimer_pyimportTimertimer=Timer()timer.start()# Or:# timer = Timer(start=True)# A one-second processsleep(1)# Printing the elapsed time. The timer will continue to run.timer.elapsed()# Output:# [timer.py] 00:00:01.001timer.pause()# A one-second process that won't be counted while the timer is paused.sleep(1)timer.resume()# Another one-second process.sleep(1)# Overriding the tag for one time only (the original tag will still be remembered).timer.elapsed('Checkpoint 1')# Output:# [Checkpoint 1] 00:00:02.002timer.set_tag('Custom title')timer.restart()# Another one-second process.sleep(1)# Storing the elapsed time to a variable as a float while hiding the output.elapsed=timer.elapsed(print=False)print(elapsed)# Output:# 00:00:01.001timer.stop()# Output:# [Custom title] 00:00:01.001