All Projects → mjmikulski → horology

mjmikulski / horology

Licence: MIT license
timing functions, contexts and for-loops

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to horology

react-native-lightning-modal
A performant bottom modal that works using React Native Reanimated 2
Stars: ✭ 20 (-71.83%)
Mutual labels:  hacktoberfest2021
Hacktoberfest-Indonesia-2021
Event Hacktoberfest Indonesia 2021
Stars: ✭ 42 (-40.85%)
Mutual labels:  hacktoberfest2021
HomeAssistant-Tapo-Control
Control for Tapo cameras as a Home Assistant component
Stars: ✭ 327 (+360.56%)
Mutual labels:  hacktoberfest2021
ICBM-Classic
Classic 1.6.4 version of ICBM remastered for newer MC versions
Stars: ✭ 34 (-52.11%)
Mutual labels:  hacktoberfest2021
o-fish-web
Web application for the Officer's Fishery Information Sharing Hub (O-FISH). The web app allows agencies to gain insights from the aggregated information gathered during a routine vessel inspection (submitted via the web app).
Stars: ✭ 29 (-59.15%)
Mutual labels:  hacktoberfest2021
Data-Structures-and-Algorithms
No description or website provided.
Stars: ✭ 108 (+52.11%)
Mutual labels:  hacktoberfest2021
PortfolioV2
🔥 The Complete Customizable Software Developer Portfolio Template which lets you showcase your work and provides each and every detail about you as Software Developer.
Stars: ✭ 197 (+177.46%)
Mutual labels:  hacktoberfest2021
php-underscore
PHP underscore inspired &/or cloned from _.js, with extra goodies like higher order messaging
Stars: ✭ 42 (-40.85%)
Mutual labels:  hacktoberfest2021
1stHacktoberfest
Web / Android app base on Flutter(2.5.2).
Stars: ✭ 35 (-50.7%)
Mutual labels:  hacktoberfest2021
Poke-Dex
This is a small webpage that allows user to add their favourite Pokémons! This project aims to help people in creating their first pull requests and participating in Hacktoberfest 2021
Stars: ✭ 126 (+77.46%)
Mutual labels:  hacktoberfest2021
Minecraft-bedrock-json-schemas
The JSON validation schema files for Minecraft bedrock
Stars: ✭ 17 (-76.06%)
Mutual labels:  hacktoberfest2021
Rboxlo
Roblox private server
Stars: ✭ 173 (+143.66%)
Mutual labels:  hacktoberfest2021
object-gui
Object GUI - Javascript Object GUI Editor
Stars: ✭ 51 (-28.17%)
Mutual labels:  hacktoberfest2021
Research-Internships-for-UG-Students
A comprehensive list of research opportunities for undergraduate students
Stars: ✭ 35 (-50.7%)
Mutual labels:  hacktoberfest2021
hacktoberfest2021
Add your any type of project related to programming! This is a beginner-friendly repository made specifically for Hacktoberfest that helps you get your first PR. Happy Hacking !!!!!
Stars: ✭ 21 (-70.42%)
Mutual labels:  hacktoberfest2021
semantic-release
📦🚀 Fully automated version management and package publishing
Stars: ✭ 29 (-59.15%)
Mutual labels:  hacktoberfest2021
Hacktoberfest-2021-Data-Structures-and-Algorithms
This repository is mainly open to those who are looking to make some PRs for the Hacktoberfest 2021 event. In this repository, you can add programs on Data Structures and some useful algorithms for Competitive Programming.
Stars: ✭ 49 (-30.99%)
Mutual labels:  hacktoberfest2021
community-events-angular
Community Events App built with ❤️ using Angular, NgRx, Rxjs to do thrill in #hacktoberfest21
Stars: ✭ 20 (-71.83%)
Mutual labels:  hacktoberfest2021
college-management-react
This is a College management web app in MERN stack.
Stars: ✭ 42 (-40.85%)
Mutual labels:  hacktoberfest2021
ProjectSakura.github.io
Our official website, download center and blog.
Stars: ✭ 26 (-63.38%)
Mutual labels:  hacktoberfest2021

Horology

Language grade: Python Total alerts Downloads PyPI version

CircleCI

Conveniently measures the time of your loops, contexts and functions.

Installation

Simply:

pip install horology

Works with python versions 3.6, 3.7, 3.8 and 3.9. Tested on Linux, Windows and MacOS.

Usage

The following 3 tools will let you measure practically any part of your Python code.

Timing an iterable (list, tuple, generator, etc)

Quick example

from horology import Timed

animals = ['cat', 'dog', 'crocodile']

for x in Timed(animals):
    feed(x)

Result:

iteration    1: 12.0 s
iteration    2: 8.00 s
iteration    3: 100 s

total 3 iterations in 120 s
min/median/max: 8.00/12.0/100 s
average (std): 40.0 (52.0) s

More cool stuff:

You can specify where (if at all) you want each iteration and summary to be printed, eg.:

for x in Timed(animals, unit='ms', 
               iteration_print_fn=logger.debug, 
               summary_print_fn=logger.info):
    feed(x)

Timing a function with a @timed decorator

Quick example

from horology import timed

@timed
def foo():
    ...

Result:

>>> foo()
foo: 7.12 ms

More cool stuff:

Personalize time unit and name

@timed(unit='s', name='Processing took ')
def bar():
    ...

Result:

>>> bar()
Processing took 0.185 s

Timing part of code with a Timing context

Quick example

Just wrap your code using a with statement

from horology import Timing

with Timing(name='Important calculations: '):
    ...

Result:

Important calculations: 12.4 s

More cool stuff:

You can suppress default printing and directly use measured time (also within context)

with Timing(print_fn=None) as t:
    ...
    
make_use_of(t.interval)

Time units

Time units are by default automatically adjusted, for example you will see foo: 7.12 ms rather than foo: 0.007 s. If you don't like it, you can override this by setting the unit argument with one of these names: ['ns', 'us', 'ms', 's', 'min', 'h', 'd'].

Contributions

Contributions are welcomed, see contribution guide.

Internals

Horology internally measures time with perf_counter which provides the highest available resolution, see docs.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].