Created
December 2, 2009 20:58
-
-
Save jkern/247572 to your computer and use it in GitHub Desktop.
Disky The Disc Benchmarker
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
#!/usr/bin/python | |
# This is a great function for timing a function | |
def timer(fun): | |
"""timer takes the input of a function and returns the clock() time""" | |
from time import clock | |
start = clock() | |
fun | |
return clock()-start | |
def filer(path, data): | |
"""the data supplied will be binary""" | |
f = open(path, 'ab') | |
f.write(data) | |
f.close | |
def writer(): | |
"""Currently writes 100MB to E:\test.bin""" | |
MB = "\xFE" * (2**20) | |
timer_list = [] | |
counter = 0 | |
while counter < 100: | |
timer_list.append(timer(filer("E:\\test.bin", MB))) | |
counter += 1 | |
return reduce(lambda x,y: x + y, timer_list) / len(timer_list)#, reduce(lambda x,y: x + y, timer_list) | |
def main(): | |
counter = 0 | |
timer_list = [] | |
while counter < 10: | |
timer_list.append(writer()) | |
print counter + 1,"\t\t", timer_list[counter] #human readable 1 = the first iteration | |
counter +=1 | |
print "Average Time:\t", reduce(lambda x,y: x + y, timer_list) / len(timer_list) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment