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
)

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

funmark-0.1.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

funmark-0.1.1-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

Details for the file funmark-0.1.1.tar.gz.

File metadata

  • Download URL: funmark-0.1.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for funmark-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4e8e8c9fb1964aba5af1ad7fa24c35f2bc7edaa827e325b1f149669be35541b4
MD5 a7ffe63590335221d1c520d49eba6630
BLAKE2b-256 38c3ba97a5a10910d29aa2cd18bb3a6da4ed58eb3f50bc75a9545328262e15d2

See more details on using hashes here.

File details

Details for the file funmark-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: funmark-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.2

File hashes

Hashes for funmark-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5c9e91c38b9e32635f3b062d8ce5604824e059c0d5a1b2766dc6fe623d0b552
MD5 079a1eb9be317c8c1c8d8cec5ad8f8c2
BLAKE2b-256 334928a4942e69ac98cae587b1917cb2ebc607d31c1ada21d53e74e2eded4ed8

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