File: test_00_common.py

package info (click to toggle)
python-pint 0.25.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,940 kB
  • sloc: python: 20,478; makefile: 148
file content (22 lines) | stat: -rw-r--r-- 580 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
from __future__ import annotations

import subprocess
import sys


def import_pint():
    # on py37+ 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 pint"]
    p = subprocess.run(cmd, stderr=subprocess.PIPE)

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


def test_import(benchmark):
    benchmark(import_pint)