File: package.py

package info (click to toggle)
pandas 1.1.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 47,284 kB
  • sloc: python: 292,793; ansic: 8,591; sh: 608; makefile: 94
file content (25 lines) | stat: -rw-r--r-- 809 bytes parent folder | download
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
"""
Benchmarks for pandas at the package-level.
"""
import subprocess
import sys

from pandas.compat import PY37


class TimeImport:
    def time_import(self):
        if PY37:
            # on py37+ we the "-X importtime" usage gives us a more precise
            #  measurement of the import time we actually care about,
            #  without the subprocess or interpreter overhead
            cmd = [sys.executable, "-X", "importtime", "-c", "import pandas as pd"]
            p = subprocess.run(cmd, stderr=subprocess.PIPE)

            line = p.stderr.splitlines()[-1]
            field = line.split(b"|")[-2].strip()
            total = int(field)  # microseconds
            return total

        cmd = [sys.executable, "-c", "import pandas as pd"]
        subprocess.run(cmd, stderr=subprocess.PIPE)