File: package.py

package info (click to toggle)
pandas 2.2.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,784 kB
  • sloc: python: 422,228; ansic: 9,190; sh: 270; xml: 102; makefile: 83
file content (19 lines) | stat: -rw-r--r-- 623 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Benchmarks for pandas at the package-level.
"""
import subprocess
import sys


class TimeImport:
    def time_import(self):
        # 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, check=True)

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