Skip to main content

Measure execution time for each line of a function.

Project description



codepulse: Measure Execution Time for Each Line of Code

Package PyPI Latest Release PyPI Downloads
Meta Powered by codepulse License - MIT

What is codepulse?

codepulse is a Python package designed to provide detailed insights into the execution time of your code at a granular level, line by line. By meticulously tracking the execution time of each line of code, codepulse helps you identify bottlenecks, optimize performance, and gain a deeper understanding of your code's behavior.

Table of Contents

Main Features

  • Precisely measures the execution time of each line of code within a function.
  • Generates informative visualizations that highlight performance hotspots.
  • Supports integration with popular Python development environments.
  • Designed for ease of use and seamless integration into existing projects.

Where to get it

The source code is currently hosted on GitHub at: https://github.com/ar8372/codepulse

Binary installers for the latest released version are available at the Python Package Index (PyPI).

Installation

You can install codepulse using pip:

pip install codepulse

Usage

Import the Tracker module from the codepulse package, create an instance of it by passing the function you want to track as a parameter, and then utilize this instance to invoke the tracked function. When you create an instance using Tracker(fun1), it generates a wrapper around fun1 that effectively measures and records the execution time line by line.

from codepulse import Tracker

def fun1(x,y):
    m = 1
    for i in range(x*100):
        m = m * 3 
        for j in range(x*30):
            m = m + 4 
    return m 

t = Tracker(fun1)
t(3,5)

output:

  ===========================================================================================
  |> Function Name: fun1, #iter: 3, mean_time(in ms): 46.856, std_time(in_ms): 0.019
  ===========================================================================================
  | LineNo     | line                              | mean_time(in ms)     | std_time(in ms) |
  ===========================================================================================
  | 0          |     m = 1                         | 0.0                  | 0.0
  | 1          |     for i in range(x*100):        | 46.856               | 0.024
  | 2          |         m = m * 3                 | 0.0                  | 0.0
  | 3          |         for j in range(x*30):     | 15.673               | 0.003
  | 4          |             m = m + 4             | 15.611               | 0.052
  | 5          |     return m                      | nan                  | nan
  -------------------------------------------------------------------------------------------

License

This project is licensed under the MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codepulse-1.0.2.tar.gz (10.3 kB view details)

Uploaded Source

File details

Details for the file codepulse-1.0.2.tar.gz.

File metadata

  • Download URL: codepulse-1.0.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.5

File hashes

Hashes for codepulse-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8d14925c2b4be792e6adaaad0d980af6b608df800954e29dd2650191b58c6233
MD5 57089f7c21de2698d90559eb0ec33253
BLAKE2b-256 07985decb1ed7479ffc73ecea6f782550eabafb5829110a55eb4c6a466385458

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page