forked from datalad/datalad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
70 lines (51 loc) · 1.83 KB
/
core.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# ex: set sts=4 ts=4 sw=4 noet:
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
#
# See COPYING file distributed along with the datalad package for the
# copyright and license terms.
#
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
"""Benchmarks for DataLad"""
import os
import sys
import os.path as osp
from subprocess import call
from datalad.runner import (
Runner,
GitRunner,
StdOutErrCapture,
)
# Some tracking example -- may be we should track # of datasets.datalad.org
#import gc
#def track_num_objects():
# return len(gc.get_objects())
#track_num_objects.unit = "objects"
from .common import SuprocBenchmarks
scripts_dir = osp.join(osp.dirname(__file__), 'scripts')
heavyout_cmd = "{} 1000".format(osp.join(scripts_dir, 'heavyout'))
class startup(SuprocBenchmarks):
"""
Benchmarks for datalad commands startup
"""
def setup(self):
# we need to prepare/adjust PATH to point to installed datalad
# We will base it on taking sys.executable
python_path = osp.dirname(sys.executable)
self.env = os.environ.copy()
self.env['PATH'] = '%s:%s' % (python_path, self.env.get('PATH', ''))
def time_import(self):
call([sys.executable, "-c", "import datalad"])
def time_import_api(self):
call([sys.executable, "-c", "import datalad.api"])
class witlessrunner(SuprocBenchmarks):
"""Some rudimentary tests to see if there is no major slowdowns of Runner
"""
def setup(self):
self.runner = Runner()
self.git_runner = GitRunner()
def time_echo(self):
self.runner.run(["echo"])
def time_echo_gitrunner(self):
self.git_runner.run(["echo"])
def time_echo_gitrunner_fullcapture(self):
self.git_runner.run(["echo"], protocol=StdOutErrCapture)