Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Sven R. Kunze" Newsgroups: comp.lang.python Subject: benchmarking in general and using xheap Date: Fri, 19 Feb 2016 10:52:23 +0100 Lines: 40 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 3++bdxSW2I368NfaTPF36wXpjYZLlJSp7OtW0k1JBjrw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'classes,': 0.05; 'cpython': 0.05; 'url:pipermail': 0.05; 'calls.': 0.07; 'everybody,': 0.07; 'nicely': 0.07; 'strings.': 0.07; 'descriptor': 0.09; 'here?': 0.09; 'subject:using': 0.09; '2.7': 0.13; ':-/': 0.16; 'compares': 0.16; 'heap,': 0.16; 'readable': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'threw': 0.16; 'to:name:python list': 0.16; 'unittests': 0.16; 'suggested': 0.20; 'to:2**1': 0.21; 'url:02': 0.22; 'code.': 0.23; "i've": 0.25; 'idea': 0.28; 'actual': 0.28; 'reduced': 0.29; 'code': 0.30; 'push': 0.30; 'somebody': 0.30; 'post': 0.31; 'another': 0.32; 'url:python': 0.33; 'choosing': 0.33; 'operations.': 0.33; 'received:10.0': 0.34; 'best,': 0.35; 'could': 0.35; 'quite': 0.35; 'expected': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; '(and': 0.36; 'to:addr:python-list': 0.36; 'received:10': 0.37; 'expect': 0.37; 'anything': 0.38; 'sure': 0.39; 'does': 0.39; 'url:mail': 0.40; 'build': 0.40; 'to:addr:python.org': 0.40; 'received:de': 0.40; 'some': 0.40; 'your': 0.60; 'affordable': 0.63; 'here': 0.66; 'results': 0.66; 'finally': 0.70; 'integrated': 0.72; 'removal': 0.79; 'friends': 0.82; 'benchmark': 0.84; 'url:2016': 0.84; 'wrapper,': 0.84; 'approach.': 0.91; 'grew': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=mail.de; s=mail201212; t=1455875546; bh=EH8bTJd4u1bQ1aVAntUn+UhfcuZkx8RSuvlZbgnpygw=; h=To:From:Subject:Date:From; b=MrHvG7NReJbow452bZ6L00UV3Copn4xHX05JyzTqDVjsBziDyWRC3ER/CCYZZbVAB S5Rk6GULmeIT6GiVsFjxQYqbLfOHrHlJmNcigDTrH8C60WgqBzvdCojlKxAuH7Ki3t EHIj/q+PkhEdaX2YQC8a67dkXr9Q9tDuzDqQgLVI= 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: 1762 X-purgate-ID: 154282::1455875545-000009F3-D3DFD58C/0/0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21rc2 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:103174 Hi everybody, I've finally had the time to do the benchmarks and here you go: http://srkunze.blogspot.com/2016/02/the-xheap-benchmark.html The benchmark compares heapq, Heap, OrderHeap, RemovalHeap and XHeap regarding their operation heapify, push and pop. As expected wrapping results in some overhead. Most of the overhead consists of wrapper, super and descriptor calls. As with the current optimizations efforts, I expect this to be reduced even further. But even using current CPython 2.7 or 3.5, the overhead for simple heaps, heaps with a custom orders or heaps with removal can be considered affordable given the maintenance benefits. @srinivas The current removal implementation uses a index-tracking approach with quite some overhead for other operations. I am not sure if that is remediable with a mark-and-sweep approach but given the time I will definitely look into it for another benchmark post now that I have build the infrastructure for it. @all benchmark friends Not sure how you do your benchmarks, but I am somewhat dissatisfied with the current approach. I started out using unittests as they integrated nicely with my current toolchain and I could write actual code. Then I threw anything away and used timeit as suggested here https://mail.python.org/pipermail/python-list/2016-January/702571.html and grew my own set of tools around it to produce readable results; writing code as strings. :-/ And from what I know, there is no official infrastructure (tools, classes, ... such as there is for unittests) around timeit to encapsulate benchmarks, choosing a baseline, calculate ratios etc (and write code instead of strings). Does somebody have an idea here? Best, Sven