Giter VIP home page Giter VIP logo

ntropy's Introduction

ntropy - Human readable function time measuring

GitHub code size in bytes Code language count GitHub top language GitHub last commit


🗣️ About

A very simple utility to decorate your functions with that shows you how long that function took to run. Zero dependencies, uses only what Python already gives you.

🛠️ Usage

Requirements

  • python >= 3.8 (for TypedDict support)

Usage instructions

  1. Install this package with pip install ntropy-timer;
  2. Import the measure_time function and decorate the function you wish to measure:
from ntropy import measure_time
###

@measure_time
def measure_this_function(*args, **kwargs):
		# do something
  1. Then just execute the function and you should see the results in the standard output:
measure_this_function()

# > The function 'measure_this_function' took 12 seconds 389 miliseconds to run.

Parameters

Disabling the gargabe collector for more precise measurements: disable_gc (default: False)

With the disable_gc flag, you can temporarily disable Python's garbage collector while the decorated function runs. This can be useful for more accurately measuring time specific to that function, tuning outside noise down to a minimum.

Showing a more straightforward run time message: message_format (possible values: "human", "complete"; default: "human")

If you'd like to see a more standard message, showing even zero values, you can pass in the message_format="complete" parameter. It will go from:

The function 'measure_this_function' took 3 minutes 33 seconds 123 miliseconds to run.

to

The function 'measure_this_function' took 0hr 3min 33sec 123ms to run.

📋 Developing

Requirements

ntropy has no requirements to run, but it has to be developed. Clone this repository and install the dev requirements with

pip install -r dev-requirements.txt

Testing

To run tests (after installing dev dependencies):

pytest

ntropy's People

Contributors

cacauisadog avatar

Stargazers

 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.