@@ -64,6 +64,7 @@ def insert_many_rows(transaction, many_rows):
64
64
65
65
66
66
class DjangoBenchmarkTest ():
67
+ """The Django performace testing class."""
67
68
def __init__ (self ):
68
69
with connection .schema_editor () as editor :
69
70
# Create the tables
@@ -77,13 +78,6 @@ def __init__(self):
77
78
num2 = round (random .randint (0 ,100000000 ))
78
79
self ._many_rows2 .append (Author (num2 , "Pete" , "Allison" , "2.1" ))
79
80
80
- def _cleanup (self ):
81
- """Drop the test table."""
82
- with connection .schema_editor () as editor :
83
- # delete the table
84
- editor .delete_model (Author )
85
- # teardown_instance()
86
-
87
81
@measure_execution_time
88
82
def insert_one_row_with_fetch_after (self ):
89
83
author_kent = Author (
@@ -118,6 +112,12 @@ def select_many_rows(self):
118
112
if len (rows ) != 100 :
119
113
raise ValueError ("Wrong number of rows read" )
120
114
115
+ def _cleanup (self ):
116
+ """Drop the test table."""
117
+ with connection .schema_editor () as editor :
118
+ # delete the table
119
+ editor .delete_model (Author )
120
+
121
121
def run (self ):
122
122
"""Execute every test case."""
123
123
measures = {}
@@ -130,13 +130,11 @@ def run(self):
130
130
):
131
131
method (measures )
132
132
self ._cleanup ()
133
- # import pdb
134
- # pdb.set_trace()
135
133
return measures
136
134
137
135
138
136
class SpannerBenchmarkTest ():
139
- """The original Spanner performace testing class."""
137
+ """The Spanner performace testing class."""
140
138
def __init__ (self ):
141
139
self ._create_table ()
142
140
self ._one_row = (
@@ -236,10 +234,11 @@ def run(self):
236
234
237
235
@pytest .mark .django_db ()
238
236
class BenchmarkTest (unittest .TestCase ):
239
-
240
- def test_run (self ):
237
+ def setUp (self ):
241
238
setup_instance ()
242
239
setup_database ()
240
+
241
+ def test_run (self ):
243
242
django_obj = pd .DataFrame (columns = ['insert_one_row_with_fetch_after' , 'read_one_row' , 'insert_many_rows' , 'select_many_rows' ,
244
243
'insert_many_rows_with_mutations' ])
245
244
spanner_obj = pd .DataFrame (columns = ['insert_one_row_with_fetch_after' , 'read_one_row' , 'insert_many_rows' , 'select_many_rows' ,
0 commit comments