Skip to content

Commit 304d18f

Browse files
committed
A little more robust. Renamed to vbench
1 parent dabe2a4 commit 304d18f

File tree

13 files changed

+81
-22
lines changed

13 files changed

+81
-22
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ MANIFEST
1010
*.pyd
1111
*flymake*
1212
.coverage
13-
gitbench.egg-info
13+
vbench.egg-info

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
"""
1010

1111
REQUIRES = ['sqlalchemy', 'pandas']
12-
DISTNAME = 'gitbench'
12+
DISTNAME = 'vbench'
1313
LICENSE = 'BSD'
1414
AUTHOR = "Wes McKinney"
1515
AUTHOR_EMAIL = "[email protected]"
16-
URL = "https://github.com/wesm/gitbench"
16+
URL = "https://github.com/wesm/vbench"
1717
CLASSIFIERS = [
1818
'Development Status :: 2 - Pre-Alpha',
1919
'Environment :: Console',
@@ -40,8 +40,8 @@ def configuration(parent_package='', top_path=None):
4040
delegate_options_to_subpackages=True,
4141
quiet=True)
4242

43-
config.add_subpackage('gitbench')
44-
config.add_data_dir('gitbench/tests')
43+
config.add_subpackage('vbench')
44+
config.add_data_dir('vbench/tests')
4545
return config
4646

4747
if __name__ == '__main__':
File renamed without changes.
File renamed without changes.

gitbench/benchmark.py renamed to vbench/benchmark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@
1313
class Benchmark(object):
1414

1515
def __init__(self, code, setup, ncalls=None, cleanup=None,
16-
name=None, description=None):
16+
name=None, description=None, start_date=None):
1717
self.code = code
1818
self.setup = setup
1919
self.cleanup = cleanup or ''
2020
self.ncalls = ncalls
2121
self.name = name
2222
self.description = description
23+
self.start_date = start_date
2324

2425
def _setup(self):
2526
ns = globals().copy()
File renamed without changes.

gitbench/db.py renamed to vbench/db.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
from sqlalchemy import sql
66
from sqlalchemy import exceptions as exc
77

8-
from gitbench.benchmark import Benchmark
8+
from vbench.benchmark import Benchmark
99

1010
class BenchmarkDB(object):
1111
"""
12-
Persist gitbench results in a sqlite3 database
12+
Persist vbench results in a sqlite3 database
1313
"""
1414

1515
def __init__(self, dbpath):
@@ -83,6 +83,12 @@ def delete_result(self, checksum, revision):
8383
"""
8484
pass
8585

86+
def delete_error_results(self):
87+
tab = self._results
88+
ins = tab.delete()
89+
ins = ins.where(tab.c.timing == None)
90+
self.conn.execute(ins)
91+
8692
def get_benchmarks(self):
8793
stmt = sql.select([self._benchmarks])
8894
return list(self.conn.execute(stmt))
@@ -102,3 +108,4 @@ def get_benchmark_results(self, checksum):
102108
stmt = sql.select([tab],
103109
sql.and_(tab.c.bmk_checksum == checksum))
104110
return self.conn.execute(stmt)
111+

gitbench/git.py renamed to vbench/git.py

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from pandas import *
1212

13-
import gitbench.config as config
13+
import vbench.config as config
1414

1515
class Repo(object):
1616

@@ -121,10 +121,11 @@ class BenchRepo(object):
121121
"""
122122
Manage an isolated copy of a repository for benchmarking
123123
"""
124-
def __init__(self, source_dir, target_dir, build_cmds):
125-
self.source_dir = source_dir
124+
def __init__(self, source_url, target_dir, build_cmds, prep_cmd):
125+
self.source_url = source_url
126126
self.target_dir = target_dir
127127
self.build_cmds = build_cmds
128+
self.prep_cmd = prep_cmd
128129
self._copy_repo()
129130

130131
def _copy_repo(self):
@@ -136,10 +137,12 @@ def _copy_repo(self):
136137
cmd = 'rm -rf %s' % self.target_dir
137138
print cmd
138139
os.system(cmd)
139-
cmd = 'cp -r %s %s' % (self.source_dir, self.target_dir)
140+
141+
url = '[email protected]:wesm/pandas.git'
142+
cmd = 'git clone %s %s' % (url, self.target_dir)
140143
print cmd
141144
os.system(cmd)
142-
145+
self._prep()
143146
self._copy_benchmark_script()
144147

145148
def _copy_benchmark_script(self):
@@ -154,6 +157,7 @@ def switch_to_revision(self, rev):
154157
rev: git SHA
155158
"""
156159
self._checkout(rev)
160+
self._clean_pyc_files()
157161
self._build()
158162

159163
def _checkout(self, rev):
@@ -177,6 +181,32 @@ def _build(self):
177181
stdout, stderr = proc.communicate()
178182
print stdout
179183

184+
def _prep(self):
185+
cmd = ';'.join([x for x in self.prep_cmd.split('\n')
186+
if len(x.strip()) > 0])
187+
188+
print cmd
189+
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True,
190+
cwd=self.target_dir)
191+
stdout, stderr = proc.communicate()
192+
print stdout
193+
194+
def hard_clean(self):
195+
self._clean_pyc_files(('.pyc', '.pyo', 'c', 'cpp', 'so', 'pyd'))
196+
197+
def _clean_pyc_files(self, extensions=('.pyc', '.pyo')):
198+
clean_me = []
199+
for root, dirs, files in list(os.walk(self.target_dir)):
200+
for f in files:
201+
if os.path.splitext(f)[-1] in extensions:
202+
clean_me.append(os.path.join(root, f))
203+
204+
for path in clean_me:
205+
try:
206+
os.unlink(path)
207+
except Exception:
208+
pass
209+
180210

181211
def _convert_timezones(stamps):
182212
# tz = config.TIME_ZONE
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)