Skip to content

Commit

Permalink
Merge pull request #94 from jaraco/gh-102209/measure-complexity-impli…
Browse files Browse the repository at this point in the history
…ed-dirs

Measure complexity in implied_dirs
  • Loading branch information
jaraco authored Feb 25, 2023
2 parents 54602b9 + 54cd2d2 commit 63bdf88
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 47 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v3.15.0
=======

* gh-102209: ``test_implied_dirs_performance`` now tests
measures the time complexity experimentally.

v3.14.0
=======

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ testing =

# local
jaraco.itertools
func-timeout
jaraco.functools
more_itertools
big-O

docs =
# upstream
Expand Down
30 changes: 0 additions & 30 deletions tests/_context.py

This file was deleted.

8 changes: 0 additions & 8 deletions tests/_func_timeout_compat.py

This file was deleted.

9 changes: 9 additions & 0 deletions tests/_support.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import importlib
import unittest


def import_or_skip(name):
try:
return importlib.import_module(name)
except ImportError: # pragma: no cover
raise unittest.SkipTest(f'Unable to import {name}')
24 changes: 24 additions & 0 deletions tests/test_complexity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
import string

import zipp
from jaraco.functools import compose
from more_itertools import consume

from ._support import import_or_skip


big_o = import_or_skip('big_o')


class TestComplexity(unittest.TestCase):
def test_implied_dirs_performance(self):
best, others = big_o.big_o(
compose(consume, zipp.CompleteDirs._implied_dirs),
lambda size: [
'/'.join(string.ascii_lowercase + str(n)) for n in range(size)
],
max_n=1000,
min_n=1,
)
assert best <= big_o.complexities.Linear
8 changes: 0 additions & 8 deletions tests/test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@
import tempfile
import shutil
import pickle
import string
import sys
import unittest
import zipfile

import jaraco.itertools
from jaraco.functools import compose
from more_itertools import consume

import zipp

from ._test_params import parameterize, Invoked
from ._func_timeout_compat import set_timeout


def add_dirs(zf):
Expand Down Expand Up @@ -334,11 +331,6 @@ def test_joinpath_constant_time(self):
# Check the file iterated all items
assert entries.count == self.HUGE_ZIPFILE_NUM_ENTRIES

@set_timeout(3)
def test_implied_dirs_performance(self):
data = ['/'.join(string.ascii_lowercase + str(n)) for n in range(10000)]
consume(zipp.CompleteDirs._implied_dirs(data))

@pass_alpharep
def test_read_does_not_close(self, alpharep):
alpharep = self.zipfile_ondisk(alpharep)
Expand Down

0 comments on commit 63bdf88

Please sign in to comment.