11import pytest
2- pytest_plugins = [ ' pkgcraft']
2+ pytest_plugins = ( 'benchmark' , ' pkgcraft')
33
44from pkgcraft .atom import Atom as pkgcraft_atom
55from pkgcore .ebuild .atom import atom as pkgcore_atom
@@ -14,16 +14,14 @@ def test_bench_repo_iter(benchmark, lib, func, repo):
1414 from pkgcore .ebuild import repo_objs , repository
1515 repo_config = repo_objs .RepoConfig (location = str (repo .path ), disable_inst_caching = True )
1616 r = repository .UnconfiguredTree (str (repo .path ), repo_config = repo_config )
17+ pkgs = benchmark (lambda x : list (iter (x )), r )
1718 else :
18- from pkgcraft .config import Config
19- c = Config ()
20- r = c .add_repo_path (repo .path )
19+ pkgs = benchmark (lambda x : list (iter (x )), repo )
2120
22- pkgs = benchmark (lambda x : list (iter (x )), r )
2321 assert len (pkgs ) == 100
2422
2523@pytest .mark .parametrize ("lib,func" , (('pkgcraft' , pkgcraft_atom ), ('pkgcore' , pkgcore_atom )))
26- def test_bench_repo_iter_restrict (benchmark , lib , func , repo ):
24+ def test_bench_repo_iter_restrict_atom (benchmark , lib , func , repo ):
2725 # create ebuilds
2826 for i in range (100 ):
2927 repo .create_ebuild (f'cat/pkg-{ i } ' )
@@ -37,10 +35,7 @@ def test_bench_repo_iter_restrict(benchmark, lib, func, repo):
3735 r = repository .UnconfiguredTree (str (repo .path ), repo_config = repo_config )
3836 pkgs = benchmark (lambda x : list (r .itermatch (x )), atom )
3937 else :
40- from pkgcraft .config import Config
41- c = Config ()
42- r = c .add_repo_path (repo .path )
43- pkgs = benchmark (lambda x : list (r .iter_restrict (x )), atom )
38+ pkgs = benchmark (lambda x : list (repo .iter_restrict (x )), atom )
4439
4540 assert len (pkgs ) == 1
4641 assert str (pkgs [0 ].version ) == '50'
0 commit comments