07
This commit is contained in:
parent
c244dc161d
commit
ee4ad22cb6
42
07_benchmark_permissions_loading_django.py
Normal file
42
07_benchmark_permissions_loading_django.py
Normal 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
|
@ -3,6 +3,7 @@
|
||||
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. **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
|
||||
4. **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. **04_rename_with_slice.py**: rename group of files, within a single directory, using slice
|
||||
1. **05_load_json_without_dupes.py**: load json, convert to dict, raise error if there is a duplicate key
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user