This commit is contained in:
Michael Herman 2014-05-09 10:20:21 -05:00
parent c244dc161d
commit ee4ad22cb6
2 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,42 @@
import os
import time
import numpy
# temp file for benchmarking
def timeit(method):
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
all_times.append(te - ts)
print all_times
print numpy.mean(all_times)
return result
return timed
def create_new_db():
os.system("mysqladmin -u root drop DATABASE_NAME -f")
os.system("mysqladmin -u root create DATABASE_NAME -f")
os.system("./manage.py syncdb")
os.system("./manage.py migrate")
@timeit
def load_new_perms():
os.system("./manage.py LOAD_PERMS_COMMAND")
if __name__ == "__main__":
n = 0
all_times = list()
while n < 10:
create_new_db()
load_new_perms()
n += 1

View File

@ -3,6 +3,7 @@
1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo 1. **01_remove_all_pyc.md**: remove all *.pyc* files from a git repo
1. **02_find_all_links.py**: get all links from a webpage 1. **02_find_all_links.py**: get all links from a webpage
1. **03_simple_twitter_manager.py**: accessing the Twitter API, example functions 1. **03_simple_twitter_manager.py**: accessing the Twitter API, example functions
3. **04_rename_with_slice.py**: rename group of files, within a single directory, using slice 1. **04_rename_with_slice.py**: rename group of files, within a single directory, using slice
4. **05_load_json_without_dupes.py**: load json, convert to dict, raise error if there is a duplicate key 1. **05_load_json_without_dupes.py**: load json, convert to dict, raise error if there is a duplicate key
5. **06_execution_time.py**: class used for timing execution of code 1. **06_execution_time.py**: class used for timing execution of code
1.**07_benchmark_permissions_loading_django.py**: benchmark loading of permissions in Django