about-time | cool helper for tracking time | Analytics library
kandi X-RAY | about-time Summary
kandi X-RAY | about-time Summary
A cool helper for tracking time and throughput of code blocks, with beautiful human friendly renditions.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return the throughput in human readable format
- Return a human readable human throughput
- Count the number of distinct values
- Return a new human count
- Returns the content of the README md file
about-time Key Features
about-time Examples and Code Snippets
from about_time import about_time
def some_func():
import time
time.sleep(85e-3)
return True
def main():
with about_time() as at1: # <-- use it like a context manager!
at2 = about_time(some_func) # <-- use it with
from about_time import about_time
at = about_time(some_func)
print(f'The whole block took: {at.duration_human}')
print(f'And the result was: {at.result}')
def add(n, m):
return n + m
at = about_time(add, 1, 41)
# or:
at = about_time(add, n=1
from about_time import about_time
at = about_time(iterable)
for item in at:
# process item.
print(f'The whole block took: {at.duration_human}')
print(f'It was detected {at.count} elements')
print(f'The throughput was: {at.throughput_human}')
Community Discussions
Trending Discussions on about-time
QUESTION
I just went through Falsehood Programmer Beliefes about Time + number 2. Most of them fall into three groups:
- Leap years / seconds
- Nepal has UTC+0545
- DST
But there are a couple I cannot find the answer to. Can somebody here help and tell me why the following statements are false?
- The system clock will never be set to a time that is in the distant past or the far future.
- Ok, but the duration of one minute on the system clock will be pretty close to the duration of one minute on most other clocks.
And from the crouwd-version:
- Non leap years will never contain a leap day.
- Unix time is completely ignorant about anything except seconds.
- Unix time is the number of seconds since Jan 1st 1970.
- The day before Saturday is always Friday
- [Two timezones that differ will differ by an integer number of] quarter hours.
- If you parse a date time, you can read the numbers character for character, without needing to backtrack
- But if you print a date time, you can write the numbers character for character, without needing to backtrack
- You will never have to parse a format like —12Z or P12Y34M56DT78H90M12.345S
- Years have 365 or 366 days.
- Time passes at the same speed on top of a mountain and at the bottom of a valley.
- The software will never run on a space ship that is orbiting a black hole.
My guess is that there is one (or at least only a few) categories/facts about datetime / timezone I completely forgot. What is it?
...ANSWER
Answered 2018-Aug-28 at 22:25The question appears pretty broad as written, but I can address the first two and a few of the others.
- The system clock will never be set to a time that is in the distant past or the far future.
This is sometimes done by developers for testing purposes. Someone writing an application might want to make sure that their app will still work past some Y2K-like barrier in the near future. While testing this, they shouldn't need to worry that their mouse driver will go kablooie because it wasn't configured to work well when January 1, 5010 comes a day after August 28, 2018, and it doesn't know what to do when it realizes that it doesn't have any log entries for the entirety of 5009.
- Ok, but the duration of one minute on the system clock will be pretty close to the duration of one minute on most other clocks.
A computer system might be on board a spaceship near a black hole and subject to its time dilation. If it needs to maintain a connection with a computer some distance away (e.g. via some future interstellar packet radio), it shouldn't barf out, give garbled output, or bluescreen because the system clocks get out of sync by a few hours or even more.
This can also be caused by a damaged or defective internal clock. Timing crystals, EPROM, and other components tend to be pretty robust and reliable, but they are manufactured goods that do have some tolerances and do fail on rare occasions.
Also, from your second list:
- Years have 365 or 366 days.
In some countries, including the UK, the year 1752 had 354 days due to the conversion from the Julian to the Gregorian calendar.
- The day before Saturday is always Friday
In 2011, Samoa switched time zones, skipping directly from Thursday to Friday.
Time passes at the same speed on top of a mountain and at the bottom of a valley.
The software will never run on a space ship that is orbiting a black hole.
These are both references to the aforementioned time dilation.
There are really two principles here. One is relativity/time dilation, and the other is the fact that the calendar is NOT a simple static equation! It changes with the times due to political, social, and astronomical realities! Many of the other items also relate to the fact that the calendar may change in the future. It has changed before, so why wouldn't it ever change again?
There is also the matter of proposed timekeeping systems on other planets, such as Mars. Maybe we don't have computers running with them now, but maybe the software you are writing now will be installed on Martian-bound systems configured for Olympus Mons Time (hey, some people are still using Windows XP in 2018, what do you expect?).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install about-time
You can use about-time like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page