| 1 |
# ex: set sts=4 ts=4 sw=4 noet: |
| 2 |
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## |
| 3 |
# |
| 4 |
# See COPYING file distributed along with the datalad package for the |
| 5 |
# copyright and license terms. |
| 6 |
# |
| 7 |
# ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## |
| 8 |
"""Benchmarks for DataLad CLI""" |
| 9 |
|
| 10 |
import os |
| 11 |
import os.path as osp |
| 12 |
import sys |
| 13 |
from subprocess import call |
| 14 |
|
| 15 |
from .common import SuprocBenchmarks |
| 16 |
|
| 17 |
|
| 18 |
class startup(SuprocBenchmarks): |
| 19 |
""" |
| 20 |
Benchmarks for datalad command startup |
| 21 |
""" |
| 22 |
|
| 23 |
def setup(self): |
| 24 |
# we need to prepare/adjust PATH to point to installed datalad |
| 25 |
# We will base it on taking sys.executable |
| 26 |
python_path = osp.dirname(sys.executable) |
| 27 |
self.env = os.environ.copy() |
| 28 |
self.env['PATH'] = '%s:%s' % (python_path, self.env.get('PATH', '')) |
| 29 |
|
| 30 |
def time_usage_advice(self): |
| 31 |
call(["datalad"], env=self.env) |
| 32 |
|
| 33 |
def time_short_help(self): |
| 34 |
call(["datalad", "-h"], env=self.env) |
| 35 |
|
| 36 |
def time_help_np(self): |
| 37 |
call(["datalad", "--help-np"], env=self.env) |
| 38 |
|
| 39 |
def time_command_short_help(self): |
| 40 |
call(["datalad", "wtf", "-h"], env=self.env) |
| 41 |
|
| 42 |
def time_command_help_np(self): |
| 43 |
call(["datalad", "wtf", "--help-np"], env=self.env) |
| 44 |
|
| 45 |
def time_command_execution(self): |
| 46 |
# pick a command that should be minimally impacted by |
| 47 |
# non-CLI factors |
| 48 |
call(["datalad", "wtf", "-S", "python"], env=self.env) |