File: bench_fs.py

package info (click to toggle)
python-pathspec 1.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,140 kB
  • sloc: python: 9,685; makefile: 14
file content (42 lines) | stat: -rw-r--r-- 1,016 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

from pathlib import (
	Path)

import pytest
from pytest_benchmark.fixture import (
	BenchmarkFixture)

from pathspec.util import (
	iter_tree_entries,
	iter_tree_files)


@pytest.mark.benchmark(group="iter_tree_entries", warmup=True)
def bench_iter_tree_entries(benchmark: BenchmarkFixture, cpython_dir: Path):
	benchmark(run_iter_tree_entries, cpython_dir)


@pytest.mark.benchmark(group="iter_tree_files", warmup=True)
def bench_iter_tree_files_v0(benchmark: BenchmarkFixture, cpython_dir: Path):
	benchmark(run_iter_tree_files_v0, cpython_dir)


@pytest.mark.benchmark(group="iter_tree_files", warmup=True)
def bench_iter_tree_files_v1(benchmark: BenchmarkFixture, cpython_dir: Path):
	benchmark(run_iter_tree_files_v1, cpython_dir)


def run_iter_tree_entries(path: Path):
	for _ in iter_tree_entries(path):
		pass


def run_iter_tree_files_v0(path: Path):
	for entry in iter_tree_entries(path):
		if not entry.is_dir():
			pass


def run_iter_tree_files_v1(path: Path):
	for _ in iter_tree_files(path):
		pass