Skip to content

Commit

Permalink
Merge pull request #193 from jakobj/fix/cache-decorator-travis-failure
Browse files Browse the repository at this point in the history
Use more generous bounds in test_cache_decorator, improve doc
  • Loading branch information
mschmidt87 committed Jul 20, 2020
2 parents d652645 + 0f5c523 commit b39d276
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit b39d276

Please sign in to comment.