Skip to content

Commit

Permalink
Measure the complexity directly using the big-O library. Fixes python…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 25, 2023
1 parent 54602b9 commit 8c0a745
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 43 deletions.
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.

14 changes: 10 additions & 4 deletions tests/test_zipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
import unittest
import zipfile

import big_o
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,10 +334,16 @@ 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))
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.__class__ is big_o.complexities.Linear

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

0 comments on commit 8c0a745

Please sign in to comment.