-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build without memory ploting functions
- Loading branch information
1 parent
116c042
commit 22b6c3d
Showing
11 changed files
with
313 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
__pycache__/ | ||
.vscode/ | ||
build/ | ||
funmark.egg-info/ | ||
*.pyc |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# import time as t | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import tracemalloc | ||
|
||
class Benchmark: | ||
|
||
def __init__(self): | ||
self.time = [] | ||
self.memory = [] | ||
self.plot = None | ||
self.functionName = None | ||
|
||
def run(self, func, *argv): | ||
self.functionName = func.__name__ | ||
tracemalloc.start() | ||
start = t.time() | ||
# print(var) | ||
func(argv) | ||
end = t.time() | ||
__,peak = tracemalloc.get_traced_memory() | ||
tracemalloc.stop() | ||
runtime = end - start | ||
print(f'The runtime for {func.__name__} took {runtime} seconds to complete') | ||
return runtime, peak/10**6 | ||
|
||
def add(self, index, time=None, memory=None): | ||
if time: | ||
self.time.append([index, time]) | ||
if memory: | ||
self.memory.append([index, memory]) | ||
|
||
def plotGraph(self, xlabel="", ylabel="", title="", label="", show=True, plt=plt): | ||
time = np.array(self.time) | ||
plt.plot(time[:,0],time[:,1], label=label) | ||
plt.xlabel(xlabel) | ||
plt.ylabel(ylabel) | ||
plt.title(title) | ||
if show: | ||
plt.show() | ||
return plt | ||
|
||
def compare(self, xlabel="", ylabel="", title="", *argv): | ||
temp = self.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=self.functionName, show=False, plt=plt) | ||
for other in argv: | ||
# time2 = np.array(other.time, plt=temp) | ||
# plt.plot(time2[:,0],time2[:,1]) | ||
other.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=other.functionName, show=False, plt=temp) | ||
temp.legend(loc="upper right") | ||
temp.show() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# import time as t | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import tracemalloc | ||
|
||
class Benchmark: | ||
|
||
def __init__(self): | ||
self.time = [] | ||
self.memory = [] | ||
self.plot = None | ||
self.functionName = None | ||
|
||
def run(self, func, *argv): | ||
self.functionName = func.__name__ | ||
tracemalloc.start() | ||
start = t.time() | ||
# print(var) | ||
func(argv) | ||
end = t.time() | ||
__,peak = tracemalloc.get_traced_memory() | ||
tracemalloc.stop() | ||
runtime = end - start | ||
print(f'The runtime for {func.__name__} took {runtime} seconds to complete') | ||
return runtime, peak/10**6 | ||
|
||
def add(self, index, time=None, memory=None): | ||
if time: | ||
self.time.append([index, time]) | ||
if memory: | ||
self.memory.append([index, memory]) | ||
|
||
def plotGraph(self, xlabel="", ylabel="", title="", label="", show=True, plt=plt): | ||
time = np.array(self.time) | ||
plt.plot(time[:,0],time[:,1], label=label) | ||
plt.xlabel(xlabel) | ||
plt.ylabel(ylabel) | ||
plt.title(title) | ||
if show: | ||
plt.show() | ||
return plt | ||
|
||
def compare(self, xlabel="", ylabel="", title="", *argv): | ||
temp = self.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=self.functionName, show=False, plt=plt) | ||
for other in argv: | ||
# time2 = np.array(other.time, plt=temp) | ||
# plt.plot(time2[:,0],time2[:,1]) | ||
other.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=other.functionName, show=False, plt=temp) | ||
temp.legend(loc="upper right") | ||
temp.show() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import time as t | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
|
||
class Benchmark: | ||
|
||
def __init__(self): | ||
self.time = [] | ||
self.memory = [] | ||
self.plot = None | ||
self.functionName = None | ||
|
||
def run(self, func, *argv): | ||
self.functionName = func.__name__ | ||
start = t.time() | ||
# print(var) | ||
func(argv) | ||
end = t.time() | ||
runtime = end - start | ||
print(f'The runtime for {func.__name__} took {runtime} seconds to complete') | ||
return runtime | ||
|
||
def add(self, index, time=None, memory=None): | ||
self.time.append([index, time]) | ||
self.memory.append([index, memory]) | ||
|
||
def plotGraph(self, xlabel="", ylabel="", title="", label="", show=True, plt=plt): | ||
time = np.array(self.time) | ||
plt.plot(time[:,0],time[:,1], label=label) | ||
plt.xlabel(xlabel) | ||
plt.ylabel(ylabel) | ||
plt.title(title) | ||
if show: | ||
plt.show() | ||
return plt | ||
|
||
def compare(self, xlabel="", ylabel="", title="", *argv): | ||
temp = self.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=self.functionName, show=False, plt=plt) | ||
for other in argv: | ||
# time2 = np.array(other.time, plt=temp) | ||
# plt.plot(time2[:,0],time2[:,1]) | ||
other.plotGraph(xlabel=xlabel, ylabel=ylabel, title=title, label=other.functionName, show=False, plt=temp) | ||
temp.legend(loc="upper right") | ||
temp.show() | ||
|
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import setuptools | ||
with open("README.md", "r") as fh: | ||
long_description = fh.read() | ||
|
||
setuptools.setup( | ||
name='funmark', | ||
version='0.1.1.dev2', | ||
scripts=['funmark/main.py'] , | ||
author="Jai Kumar Dewani", | ||
author_email="[email protected]", | ||
description="A benchmarking tool for fuctions", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/jai-dewani/fun-mark", | ||
packages=setuptools.find_packages(), | ||
classifiers=[ | ||
"Development Status :: 2 - Pre-Alpha", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.5", | ||
"Programming Language :: Python :: 3.4", | ||
"Programming Language :: Python :: 3.3", | ||
"Programming Language :: Python :: 3.2", | ||
"Programming Language :: Python :: 3.1", | ||
"Programming Language :: Python :: 3.0", | ||
], | ||
install_requires=[ | ||
"numpy", "matplotlib" | ||
], | ||
entry_points={ | ||
'console_scripts': ['funmark=funmar:main'], | ||
} | ||
) | ||
|
||
''' | ||
Run these to deploy | ||
python setup.py sdist bdist_wheel | ||
twine upload --repository testpypi dist/* | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# import random | ||
# import time | ||
|
||
# class MyTimer(): | ||
|
||
# def __init__(self): | ||
# self.start = time.time() | ||
|
||
# def __enter__(self): | ||
# return self | ||
|
||
# def __exit__(self, exc_type, exc_val, exc_tb): | ||
# end = time.time() | ||
# runtime = end - self.start | ||
# msg = 'The function took {time} seconds to complete' | ||
# print(msg.format(time=runtime)) | ||
|
||
|
||
# def long_runner(): | ||
# for x in range(5): | ||
# sleep_time = random.choice(range(1,5)) | ||
# time.sleep(sleep_time) | ||
|
||
# def sort(ar): | ||
# ar.sort() | ||
# return ar | ||
|
||
# if __name__ == '__main__': | ||
# for i in range(2,7): | ||
# with MyTimer(): | ||
# ar = [random.randint(1,10**3) for i in range(10**i)] | ||
# sort(ar) | ||
|
||
# --------------------------------------------------------------- | ||
|
||
|
||
# import random | ||
# import time | ||
|
||
# def timerfunc(func): | ||
# """ | ||
# A timer decorator | ||
# """ | ||
# def function_timer(*args, **kwargs): | ||
# """ | ||
# A nested function for timing other functions | ||
# """ | ||
# start = time.time() | ||
# value = func(*args, **kwargs) | ||
# end = time.time() | ||
# runtime = end - start | ||
# msg = "The runtime for {func} took {time} seconds to complete" | ||
# print(msg.format(func=func.__name__, | ||
# time=runtime)) | ||
# return value | ||
# return function_timer | ||
|
||
|
||
# @timerfunc | ||
# def long_runner(): | ||
# for x in range(5): | ||
# sleep_time = random.choice(range(1,5)) | ||
# time.sleep(sleep_time) | ||
|
||
# @timerfunc | ||
# def sort(ar): | ||
# ar.sort() | ||
# return ar | ||
|
||
# if __name__ == '__main__': | ||
# for i in range(2,7): | ||
# ar = [random.randint(1,10**3) for i in range(10**i)] | ||
# sort(ar) | ||
|
||
# ---------------------------------------------------------------- | ||
|
||
|
||
# import matplotlib.pyplot as plt | ||
# ar1 = [1,2,3,4] | ||
# ar2 = [25,7,0,2] | ||
# ar3 = [16,74,36,22] | ||
# ar4 = [1,2,3,4] | ||
|
||
# def test1(): | ||
# plt.plot(ar1,ar2) | ||
# return plt | ||
|
||
# def test2(plt): | ||
# plt.plot(ar1,ar3) | ||
# # plt.show() | ||
# return plt | ||
|
||
# temp = test1() | ||
# temp = test2(temp) | ||
# temp.plot(ar1,ar4) | ||
# temp.show() |