Skip to content

Commit ee4ad22

Browse files
committed
07
1 parent c244dc1 commit ee4ad22

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
importos
2+
importtime
3+
importnumpy
4+
5+
# temp file for benchmarking
6+
7+
8+
deftimeit(method):
9+
10+
deftimed(*args, **kw):
11+
ts=time.time()
12+
13+
result=method(*args, **kw)
14+
te=time.time()
15+
all_times.append(te-ts)
16+
17+
printall_times
18+
printnumpy.mean(all_times)
19+
returnresult
20+
21+
returntimed
22+
23+
24+
defcreate_new_db():
25+
os.system("mysqladmin -u root drop DATABASE_NAME -f")
26+
os.system("mysqladmin -u root create DATABASE_NAME -f")
27+
os.system("./manage.py syncdb")
28+
os.system("./manage.py migrate")
29+
30+
31+
@timeit
32+
defload_new_perms():
33+
os.system("./manage.py LOAD_PERMS_COMMAND")
34+
35+
36+
if__name__=="__main__":
37+
n=0
38+
all_times=list()
39+
whilen<10:
40+
create_new_db()
41+
load_new_perms()
42+
n+=1

‎readme.md‎

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

0 commit comments

Comments
(0)