Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #64667
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: generate De Bruijn sequence memory and string vs lists |
| Date | 2014-01-24 09:23 +0100 |
| Organization | None |
| References | (4 earlier) <lbrst6$vel$1@ger.gmane.org> <lbrugd$k3a$1@ger.gmane.org> <CALyJZZU2J3n67LwF1a2-6eeMZ=J18zbj8h+QV-w7Ujz=kHkgOw@mail.gmail.com> <lbs0nm$f4t$1@ger.gmane.org> <CALyJZZU8R8pn9sCNgTqn9ieajayjFjkoG6sQCS6xWWLhxhWm-w@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5932.1390551780.18130.python-list@python.org> (permalink) |
Vincent Davis wrote: > Excellent Peter! > I have a question, the times reported don't make sense to me, for example > $ python3 -m timeit -s 'from debruijn_compat import debruijn_bytes as d' > 'd(4, 8)' > 100 loops, best of 3: 10.2 msec per loop > This took ~4 secs (stop watch) which is much more that 10*.0102 Why is > this? Look at the output, it's "100 loops" 100 * 10 msec == 1 sec together with "best of 3" you are already at 3 sec, minimum as it is the "best" run. Then, how do you think Python /knows/ that it has to repeat the code 10 times on my "slow" and 100 times on your "fast" machine? It runs the bench once, then 10, then 100, then 1000 times -- until there's a run that takes 0.2 secs or more. The total expected minimum time without startup overhead is then +----calibration------+ +-measurement--+ (1 + 10 + 100) * 10msec + 3 * 100 * 10msec or about 4 secs. > $ python3 -m timeit -s 'from debruijn_compat import debruijn_bytes as d' > 'd(4, 11)' > 10 loops, best of 3: 480 msec per loop​ > This took ~20 secs vs .480*10 >>> .480*(1 + 10 + 3*10) 19.68 > d(4, 14) takes about 24 seconds (one run) This is left as an exercise ;)
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: generate De Bruijn sequence memory and string vs lists Peter Otten <__peter__@web.de> - 2014-01-24 09:23 +0100
csiph-web