File: cli.py

package info (click to toggle)
datalad 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,148 kB
  • sloc: python: 69,414; sh: 1,521; makefile: 220
file content (48 lines) | stat: -rw-r--r-- 1,460 bytes parent folder | download | duplicates (2)
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
# 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 CLI"""

import os
import os.path as osp
import sys
from subprocess import call

from .common import SuprocBenchmarks


class startup(SuprocBenchmarks):
    """
    Benchmarks for datalad command 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_usage_advice(self):
        call(["datalad"], env=self.env)

    def time_short_help(self):
        call(["datalad", "-h"], env=self.env)

    def time_help_np(self):
        call(["datalad", "--help-np"], env=self.env)

    def time_command_short_help(self):
        call(["datalad", "wtf", "-h"], env=self.env)

    def time_command_help_np(self):
        call(["datalad", "wtf", "--help-np"], env=self.env)

    def time_command_execution(self):
        # pick a command that should be minimally impacted by
        # non-CLI factors
        call(["datalad", "wtf", "-S", "python"], env=self.env)