Skip to main content

A benchmarking tool for fuctions

Project description

FunMark

A package to bench-mark python fun-ctions

Installation

pip install funmark

QuickStart

Importing Benchmarking module of funmark

Funmark has class name Benchmark which you can import using

import funmark
#Bench is an object of Benchmark class
bench = funmark.Benchmark()

or

from funmark import Benchmark
#Bench is an object of Benchmark class
bench = Benchmark()

Calculating Runtime and memory consumed by a function

def doSomecCalculation(aList, i, j):
    '''
    doing some calculations
    '''
    return a 

bench = Benchmark()

'''
Benchmark.run() runs your function and returns time and memory used up by your function in seconds and KB
logs: True/Fasle(True by default)(not necessary) Prints information about runtime and memory after every run statment
'''
time, memory = bench.run(doSomecCalculation, aList, i, j, logs=True)

'''
Benchmark.add() saves the record to its object
The first parameter is the X-cordinate while drawing the graph, it can be anything like length of list or size of graph or equivalent
'''
bench.add(len(aList), time, memory)

Make Sure you do add many points with different values to get a good result while representing your data in a graph

Plotting Time and Memory used by function in Graph

'''
Input:
xlabel: str, Title of X-axis
ylabel: str, Title of Y-axis
title: Title of plot
label: Label for legend in graph
show: True/False, Used to toggle the last line plt.show() | Ture -> It will plot the graph

Output:
plotObject: matplotlib.pyplot Object, you can use this object to further make changes in the plot just make sure to set show=False, If the graph is plot then you won't be able make any channges
'''
plotObject = bench.plotTime(
        xlabel="Size of array",
        ylabel="Time Taken",
        title="Time vs size of list",
        label="doSomecCalculation function",
        show=True
                )

'''
Input:
xlabel: str, Title of X-axis
ylabel: str, Title of Y-axis
title: Title of plot
label: Label for legend in graph
show: True/False, Used to toggle the last line plt.show() | Ture -> It will plot the graph

Output:
plotObject: matplotlib.pyplot Object, you can use this object to further make changes in the plot just make sure to set show=False, If the graph is plot then you won't be able make any channges
'''
plotObject = bench.plotMemory(
        xlabel="Size of array",
        ylabel="Time Taken",
        title="Time vs size of list",
        label="doSomecCalculation function",
        show=True
                )

Comparing performance of two different functions

'''
Input:
xlabel: str, Title of X-axis
ylabel: str, Title of Y-axis
title: Title of plot

Output:
A Graph with combined plot of all Benchmark Objects passed in parameter including the one from which method is called.
'''
bench_1.compareTime(
        xlabel="Size of array",
        ylabel="Time Taken",
        title="Time vs size of list",
        bench_2,
        bench_3,
        .
        .
        bench_n
)

bench_1.compareMemory(
        xlabel="Size of array",
        ylabel="Time Taken",
        title="Time vs size of list",
        bench_2,
        bench_3,
        .
        .
        bench_n
)

Download files

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

Files for funmark, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size funmark-0.1.1.tar.gz (3.6 kB) File type Source Python version None Upload date Hashes View
Filename, size funmark-0.1.1-py3-none-any.whl (18.4 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page