28
28
29
29
import shutil
30
30
import os
31
+ import sys
31
32
import argparse
32
33
import tempfile
33
34
import time
@@ -92,7 +93,6 @@ def get_results_df(db, rev):
92
93
def prprint (s ):
93
94
print ("*** %s" % s )
94
95
95
-
96
96
def main ():
97
97
from pandas import DataFrame
98
98
from vbench .api import BenchmarkRunner
@@ -109,18 +109,31 @@ def main():
109
109
args .log_file = os .path .abspath (
110
110
os .path .join (REPO_PATH , 'vb_suite.log' ))
111
111
112
+ if args .outdf :
113
+ # not bullet-proof but enough for us
114
+ if os .path .sep not in args .outdf :
115
+ args .outdf = os .path .join (os .curdir , args .outdf )
116
+
117
+ if args .log_file :
118
+ # not bullet-proof but enough for us
119
+ if os .path .sep not in args .log_file :
120
+ args .log_file = os .path .join (os .curdir , args .log_file )
121
+
112
122
random .seed (args .seed )
113
123
np .random .seed (args .seed )
114
124
115
125
TMP_DIR = tempfile .mkdtemp ()
116
126
prprint ("TMP_DIR = %s" % TMP_DIR )
117
127
prprint ("LOG_FILE = %s\n " % args .log_file )
118
128
129
+ saved_dir = os .path .curdir
130
+ # move away from the pandas root dit, to avoid possible import
131
+ # surprises
132
+ os .chdir (os .path .dirname (os .path .abspath (__file__ )))
133
+
119
134
benchmarks = [x for x in benchmarks if re .search (args .regex ,x .name )]
120
135
121
136
try :
122
- logfile = open (args .log_file , 'w' )
123
-
124
137
prprint ("Opening DB at '%s'...\n " % DB_PATH )
125
138
db = BenchmarkDB (DB_PATH )
126
139
@@ -136,6 +149,8 @@ def main():
136
149
module_dependencies = dependencies )
137
150
138
151
repo = runner .repo # (steal the parsed git repo used by runner)
152
+ h_head = args .target_commit or repo .shas [- 1 ]
153
+ h_baseline = args .base_commit
139
154
140
155
# ARGH. reparse the repo, without discarding any commits,
141
156
# then overwrite the previous parse results
@@ -144,9 +159,6 @@ def main():
144
159
repo .timestamps , repo .authors ) = _parse_commit_log (None ,REPO_PATH ,
145
160
args .base_commit )
146
161
147
- h_head = args .target_commit or repo .shas [- 1 ]
148
- h_baseline = args .base_commit
149
-
150
162
prprint ('Target [%s] : %s\n ' % (h_head , repo .messages .get (h_head , "" )))
151
163
prprint ('Baseline [%s] : %s\n ' % (h_baseline ,
152
164
repo .messages .get (h_baseline , "" )))
@@ -178,7 +190,6 @@ def main():
178
190
totals = totals .dropna (
179
191
).sort ("ratio" ).set_index ('name' ) # sort in ascending order
180
192
181
-
182
193
hdr = ftr = """
183
194
-----------------------------------------------------------------------
184
195
Test name | target[ms] | base[ms] | ratio |
@@ -199,28 +210,28 @@ def main():
199
210
s += 'Base [%s] : %s\n \n ' % (
200
211
h_baseline , repo .messages .get (h_baseline , "" ))
201
212
213
+ logfile = open (args .log_file , 'w' )
202
214
logfile .write (s )
203
215
logfile .close ()
204
216
205
217
prprint (s )
206
218
prprint ("Results were also written to the logfile at '%s'" %
207
219
args .log_file )
208
220
221
+ if args .outdf :
222
+ prprint ("The results DataFrame was written to '%s'\n " % args .outdf )
223
+ totals .save (args .outdf )
224
+
209
225
finally :
210
226
# print("Disposing of TMP_DIR: %s" % TMP_DIR)
211
227
shutil .rmtree (TMP_DIR )
212
- logfile . close ( )
228
+ os . chdir ( saved_dir )
213
229
214
- if args .outdf :
215
230
216
- opath = os .path .abspath (os .path .join (os .curdir ,args .outdf ))
217
- prprint ("The results DataFrame was written to '%s'\n " % opath )
218
- totals .save (opath )
219
231
220
232
# hack , vbench.git ignores some commits, but we
221
233
# need to be able to reference any commit.
222
234
# modified from vbench.git
223
-
224
235
def _parse_commit_log (this ,repo_path ,base_commit = None ):
225
236
from vbench .git import parser , _convert_timezones
226
237
from pandas import Series
0 commit comments