Git Product home page Git Product logo

tictoc's Introduction

A logo with the word tictoc followed by a stopwatch emoji A logo with the word tictoc followed by a stopwatch emoji

Fast, simple and accurate Python timing. Written in Rust.

badge badge badge

Installation

Install with pip.

$ python -m pip install tictoc

Usage

Import and initialise. The module must be initialised to be used!

import tictoc
t = tictoc.init()

Begin timing with tic(), and stop with toc().

t.tic()
# some code
t.toc()

When toc is called, the results are saved. They can be accessed with the following syntax:

t.results.{unit}

The available units are:

t.results.nanos   # u128
t.results.micros  # u128
t.results.millis  # u128
t.results.seconds # f64

Full example

import time

import tictoc
t = tictoc.init()

t.tic()       # start timing
time.sleep(3) # sleep for 3 seconds
t.toc()       # stop timing

print(t.results.seconds)
# >>> 3.000457715

tictoc's People

Contributors

andrwcnln avatar

Stargazers

Sven Sackers avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.