Giter Site home page Giter Site logo

perf_plot's Introduction

perf_plot

A Python performance measuring and visualization tool using gnuplot.

Example Usage:

Plot measuring two ways to unpack a dictionary Plot measuring two ways to unpack a dictionary

from perf_plot import timeit, perf_test
import sys

sys.dont_write_bytecode = 1  # Include this to prevent pycache

d = dict()


@timeit
def key_test(num: int):
    vals = d.values()


def make_dict(num: int):
    d = {key: key for key in range(num)}


@timeit
def unpack_test(num: int):
    vals = [*d]


perf_test(
    [
        unpack_test,
        key_test,
    ],
    begin=10**3,
    bound=10**5,
    step=10**3,
    callbacks=[make_dict],
)

Prerequisites

You must have gnuplot installed to use this tool.

API

perf_test function

def perf_test(funcs: list, begin=1, bound=10000, step=100, callbacks=[]):

Run a list of functions with a range of inputs, time them, and plot their performance.

list funcs

A list of tester functions that:

  • Each take an int, and
  • Do some comparable operations that scale accordingly

e.g [labmda x: [i for i in range(x)], lamba y: (i for i in range(y))]

int begin

The lower bound of the test, defaults to 1

int bound

The upper bound of the test, defaults to 10000

int step

How much to increment for each iteration, defaults to 100

list callbacks

A list of callbacks to run before testing each function, defaults to []

@timeit decorator

@timeit
def example_func(n):  # Replace with a function you want to time
    return n * 2

@timeit decorator: Time a function

perf_plot's People

Contributors

makaze avatar

Watchers

 avatar  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.