Exercise 1

On my laptop I get;

time python slow.py
The best score 21439.0 comes from pattern MDC053363.000_9241
python slow.py  3.57s user 0.13s system 111% cpu 3.322 total

This shows that the script took 3.322 seconds (so, about 3.3 seconds) to run.

I should repeat this a few times to be sure;

Run 1: 3.334 s
Run 2: 3.218 s
Run 3: 3.266 s
Run 4: 3.274 s

Exercise 2

import slow
(ids, varieties, data) = slow.load_and_parse_data(5)
timeit(slow.load_and_parse_data(5))
3.09 ms ± 7.95 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
scores = slow.calculate_scores(data)
timeit(slow.calculate_scores(data))
3.14 s ± 6.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
best_pattern = slow.get_index_of_best_score(scores)
timeit(slow.get_index_of_best_score(scores))
5.39 µs ± 29.7 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)

Back