Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102392
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | "Sven R. Kunze" <srkunze@mail.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Heap Implementation |
| Date | Mon, 1 Feb 2016 20:32:06 +0100 |
| Lines | 44 |
| Message-ID | <mailman.6.1454355132.3032.python-list@python.org> (permalink) |
| References | <mailman.148.1454194055.2338.python-list@python.org> <56ad6800$0$14486$c3e8da3@news.astraweb.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de 5nhijY/D6LMw3W/vdmtMUwcUk6t1qK7WpXIqwLo18F9g== |
| Return-Path | <srkunze@mail.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.008 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'wrapper': 0.07; 'machines.': 0.09; 'python': 0.10; 'weird': 0.15; "'from": 0.16; '1))': 0.16; '2016': 0.16; 'heapq': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; "wouldn't": 0.16; '>>>': 0.20; 'to:2**1': 0.21; 'thanks,': 0.24; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'skip:( 20': 0.28; "d'aprano": 0.33; 'steven': 0.33; 'received:10.0': 0.34; 'best,': 0.35; 'sometimes': 0.35; 'but': 0.36; 'tool': 0.36; 'faster': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'doing': 0.38; 'january': 0.38; 'wrong': 0.38; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'behavior': 0.61; 'charset:windows-1252': 0.62; 'sunday': 0.72; 'maybe,': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1454355129; bh=0OKghH9DLYk7Mnj8Jm3Po7zAbktpaNmM+V7IOnxGkkE=; h=Subject:To:References:From:Date:In-Reply-To:From; b=xnoLksMB2N9OQ2/v4hIUN4xi795hGw96yU7+yqTPbtMzs3LSRWr6UFfeCT+R1ASFL H0CXiMi2yKbew13FoN3RqmkwScC8JGuogrJh3EY+Z6gBEGRVQGEUL2y+WuVAkuLJzF 8BDLAZhGf+KUv9qI992uiwgTUvLuqBd4jzp/PNVQ= |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
| In-Reply-To | <56ad6800$0$14486$c3e8da3@news.astraweb.com> |
| X-purgate | clean |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate-type | clean |
| X-purgate-Ad | Categorized by eleven eXpurgate (R) http://www.eleven.de |
| X-purgate | This mail is considered clean (visit http://www.eleven.de for further information) |
| X-purgate | clean |
| X-purgate-size | 1698 |
| X-purgate-ID | 154282::1454355129-000018ED-8EE1CD30/0/0 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102392 |
Show key headers only | View raw
On 31.01.2016 02:48, Steven D'Aprano wrote:
> On Sunday 31 January 2016 09:47, Sven R. Kunze wrote:
>
>> @all
>> What's the best/standardized tool in Python to perform benchmarking?
> timeit
Thanks, Steven.
Maybe, I am doing it wrong but I get some weird results:
>>> min(timeit.Timer('for _ in range(10000): heappop(h)', 'from heapq
import heappop; h=list(range(10000000))').repeat(10, 1)),
min(timeit.Timer('for _ in range(10000): h.pop()', 'from xheap import
Heap; h=Heap(range(10000000))').repeat(10, 1))
(0.017267618000005314, 0.01615345600021101)
>>> min(timeit.Timer('for _ in range(100000): heappop(h)', 'from heapq
import heappop; h=list(range(10000000))').repeat(10, 1)),
min(timeit.Timer('for _ in range(100000): h.pop()', 'from xheap import
Heap; h=Heap(range(10000000))').repeat(10, 1))
(0.12321608699949138, 0.13042051299999002)
>>> min(timeit.Timer('for _ in range(10000): heappop(h)', 'from heapq
import heappop; h=list(range(1000000))').repeat(10, 1)),
min(timeit.Timer('for _ in range(10000): h.pop()', 'from xheap import
Heap; h=Heap(range(1000000))').repeat(10, 1))
(0.010081621999233903, 0.008791901999757101)
>>> min(timeit.Timer('for _ in range(1000000): heappop(h)', 'from heapq
import heappop; h=list(range(10000000))').repeat(10, 1)),
min(timeit.Timer('for _ in range(1000000): h.pop()', 'from xheap import
Heap; h=Heap(range(10000000))').repeat(10, 1))
(0.6218949679996513, 0.7172151949998806)
How can it be that my wrapper is sometimes faster and sometimes slower
than heapq? I wouldn't mind slower, but faster*?
Best,
Sven
* that behavior is reproducible also for other combos and other machines.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Heap Implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-01-30 23:47 +0100
Re: Heap Implementation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-31 12:48 +1100
Re: Heap Implementation "Sven R. Kunze" <srkunze@mail.de> - 2016-02-01 20:32 +0100
Re: Heap Implementation Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-02-02 16:38 +1100
Re: Heap Implementation Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-02-02 14:53 +0000
csiph-web