@@ -38,34 +38,34 @@ def init_book():
38
38
39
39
)
40
40
41
- print ("Doc initialization: %.3fus" % (timeit (init_book , 1000 ) * 10 ** 6 ))
41
+ print ("Doc initialization: %.3fus" % (timeit (init_book , 1000 ) * 10 ** 6 ))
42
42
43
43
b = init_book ()
44
- print ("Doc getattr: %.3fus" % (timeit (lambda : b .name , 10000 ) * 10 ** 6 ))
44
+ print ("Doc getattr: %.3fus" % (timeit (lambda : b .name , 10000 ) * 10 ** 6 ))
45
45
46
46
print (
47
47
"Doc setattr: %.3fus"
48
- % (timeit (lambda : setattr (b , "name" , "New name" ), 10000 ) * 10 ** 6 ) # noqa B010
48
+ % (timeit (lambda : setattr (b , "name" , "New name" ), 10000 ) * 10 ** 6 ) # noqa B010
49
49
)
50
50
51
- print ("Doc to mongo: %.3fus" % (timeit (b .to_mongo , 1000 ) * 10 ** 6 ))
51
+ print ("Doc to mongo: %.3fus" % (timeit (b .to_mongo , 1000 ) * 10 ** 6 ))
52
52
53
- print ("Doc validation: %.3fus" % (timeit (b .validate , 1000 ) * 10 ** 6 ))
53
+ print ("Doc validation: %.3fus" % (timeit (b .validate , 1000 ) * 10 ** 6 ))
54
54
55
55
def save_book ():
56
56
b ._mark_as_changed ("name" )
57
57
b ._mark_as_changed ("tags" )
58
58
b .save ()
59
59
60
- print ("Save to database: %.3fus" % (timeit (save_book , 100 ) * 10 ** 6 ))
60
+ print ("Save to database: %.3fus" % (timeit (save_book , 100 ) * 10 ** 6 ))
61
61
62
62
son = b .to_mongo ()
63
63
print (
64
- "Load from SON: %.3fus" % (timeit (lambda : Book ._from_son (son ), 1000 ) * 10 ** 6 )
64
+ "Load from SON: %.3fus" % (timeit (lambda : Book ._from_son (son ), 1000 ) * 10 ** 6 )
65
65
)
66
66
67
67
print (
68
- "Load from database: %.3fus" % (timeit (lambda : Book .objects [0 ], 100 ) * 10 ** 6 )
68
+ "Load from database: %.3fus" % (timeit (lambda : Book .objects [0 ], 100 ) * 10 ** 6 )
69
69
)
70
70
71
71
def create_and_delete_book ():
@@ -75,7 +75,7 @@ def create_and_delete_book():
75
75
76
76
print (
77
77
"Init + save to database + delete: %.3fms"
78
- % (timeit (create_and_delete_book , 10 ) * 10 ** 3 )
78
+ % (timeit (create_and_delete_book , 10 ) * 10 ** 3 )
79
79
)
80
80
81
81
@@ -101,9 +101,9 @@ def init_company():
101
101
)
102
102
103
103
company = init_company ()
104
- print ("Big doc to mongo: %.3fms" % (timeit (company .to_mongo , 100 ) * 10 ** 3 ))
104
+ print ("Big doc to mongo: %.3fms" % (timeit (company .to_mongo , 100 ) * 10 ** 3 ))
105
105
106
- print ("Big doc validation: %.3fms" % (timeit (company .validate , 1000 ) * 10 ** 3 ))
106
+ print ("Big doc validation: %.3fms" % (timeit (company .validate , 1000 ) * 10 ** 3 ))
107
107
108
108
company .save ()
109
109
@@ -112,17 +112,17 @@ def save_company():
112
112
company ._mark_as_changed ("contacts" )
113
113
company .save ()
114
114
115
- print ("Save to database: %.3fms" % (timeit (save_company , 100 ) * 10 ** 3 ))
115
+ print ("Save to database: %.3fms" % (timeit (save_company , 100 ) * 10 ** 3 ))
116
116
117
117
son = company .to_mongo ()
118
118
print (
119
119
"Load from SON: %.3fms"
120
- % (timeit (lambda : Company ._from_son (son ), 100 ) * 10 ** 3 )
120
+ % (timeit (lambda : Company ._from_son (son ), 100 ) * 10 ** 3 )
121
121
)
122
122
123
123
print (
124
124
"Load from database: %.3fms"
125
- % (timeit (lambda : Company .objects [0 ], 100 ) * 10 ** 3 )
125
+ % (timeit (lambda : Company .objects [0 ], 100 ) * 10 ** 3 )
126
126
)
127
127
128
128
def create_and_delete_company ():
@@ -132,7 +132,7 @@ def create_and_delete_company():
132
132
133
133
print (
134
134
"Init + save to database + delete: %.3fms"
135
- % (timeit (create_and_delete_company , 10 ) * 10 ** 3 )
135
+ % (timeit (create_and_delete_company , 10 ) * 10 ** 3 )
136
136
)
137
137
138
138
0 commit comments