Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use more generous bounds in test_cache_decorator, improve doc #193

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ def evaluate_objective_on_list(x):
# integration; the speedup of the second call with respect to the
# first can nevertheless be tested

# first call should take long due to sleep
# first call should take long due to sleep; at least 90% of the
# sleep time; to account for possible timing measurement
# inaccuracies we do not choose 100%
t0 = time.time()
evaluate_objective_on_list(x)
assert (time.time() - t0) > (sleep_time / 2.0)
assert (time.time() - t0) > (0.9 * sleep_time)

# second call should be faster as result is retrieved from cache
# second call should be faster as result is retrieved from cache;
# at most 40% of the sleep time; to account for possible timing
# measurement inaccuracies and process spin up/down time in
# TravisCI we should not choose less
t0 = time.time()
evaluate_objective_on_list(x)
assert (time.time() - t0) < (sleep_time / 5.0)
assert (time.time() - t0) < (0.4 * sleep_time)


def test_cache_decorator_consistency():
Expand Down