473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

On benchmarks, heaps, priority queues

I've been wondering about benchmarks recently.

What is a fair benchmark?

How should benchmarks be vetted or judged?

I decided to see what you folks thought, so for discussion I
compared two priority queue implementations I
published for Python in 1995 against the "heap" priority
queue implementation added to the python distribution
recently (python 2.3+).

My implementations and the benchmark code are in

http://xsdb.sourceforge.net/bench/pq3.py

(benchmark code near the bottom of the file). The python
standard implementation should be in your Lib/ directory.

Below please find the numerical results of the benchmarks.
They compare the implementations

PQPython23 - the Lib implementation
PQ0 - my insertion sort based variant
PQueue - my "heap" based variant
(like PQPython23, but different).

There are 2 benchmarks used.

insertBench
-- which does insertions followed by deletes.
mixBench
-- which does insertions and deletes mixed together.

Here is my summary of the results:

1) For sizes less than 10000 the insertion
sort PQ0 is always better.

2) For insertBench sized >10000 PQ0 is very
bad and the other two are comparable with
PQPython23 always a little faster.

3) For mixBench both of my implementations are
better than the Python23 implementation for
all sizes tested, but PQ0 is far superior.

Here is my analysis of the results:

1) The python23 implementation is best when you
expect to be doing mainly inserts with few deletions
and the expected size is >10000 (otherwise use pq0).

2) PQ0 is best if you expect to be doing many deletions
interspersed with many inserts.

3) PQueue is generally worse than the other two
unless you want to use a non-standard comparison
function (which the others don't support).

My questions to you:

Are my conclusions valid?

What is a better way to perform and publish benchmarks?

-- thanks, Aaron Watters

===
JUVENILE COURT TO TRY SHOOTING SUSPECT
-- a "real life headline" (that should work)

ENCLOSURE: run of
http://xsdb.sourceforge.net/bench/pq3.py on my machine.
=======================

BENCHMARKS FOR 1000

insertBench
__main__.PQPython23 on 1000 elapsed 0.039999961853 got 1000
__main__.PQ0 on 1000 elapsed 0.00999999046326 got 1000
__main__.PQueue on 1000 elapsed 0.0299999713898 got 1000

mixBench
__main__.PQPython23 on 1000 elapsed 0.00999999046326 got 502
__main__.PQ0 on 1000 elapsed 0.0 got 502
__main__.PQueue on 1000 elapsed 0.00999999046326 got 502

BENCHMARKS FOR 10000

insertBench
__main__.PQPython23 on 10000 elapsed 0.261000156403 got 10000
__main__.PQ0 on 10000 elapsed 0.209999799728 got 10000
__main__.PQueue on 10000 elapsed 0.361000061035 got 10000

mixBench
__main__.PQPython23 on 10000 elapsed 0.0599999427795 got 5003
__main__.PQ0 on 10000 elapsed 0.0500001907349 got 5003
__main__.PQueue on 10000 elapsed 0.0699999332428 got 5003

BENCHMARKS FOR 100000

insertBench
__main__.PQPython23 on 100000 elapsed 3.24500012398 got 100000
__main__.PQ0 on 100000 elapsed 7.93099999428 got 100000
__main__.PQueue on 100000 elapsed 4.82699990273 got 100000

mixBench
__main__.PQPython23 on 100000 elapsed 0.641000032425 got 50000
__main__.PQ0 on 100000 elapsed 0.470999956131 got 50000
__main__.PQueue on 100000 elapsed 0.651000022888 got 50000

BENCHMARKS FOR 200000

insertBench
__main__.PQPython23 on 200000 elapsed 6.98000001907 got 200000
__main__.PQ0 on 200000 elapsed 28.3209998608 got 200000
__main__.PQueue on 200000 elapsed 10.4350001812 got 200000

mixBench
__main__.PQPython23 on 200000 elapsed 1.29099988937 got 100001
__main__.PQ0 on 200000 elapsed 0.911999940872 got 100001
__main__.PQueue on 200000 elapsed 1.33200001717 got 100001

BENCHMARKS FOR 300000

insertBench
__main__.PQPython23 on 300000 elapsed 10.9159998894 got 300000
__main__.PQ0 on 300000 elapsed 69.6300001144 got 300000
__main__.PQueue on 300000 elapsed 19.3279998302 got 300000

mixBench
__main__.PQPython23 on 300000 elapsed 2.4430000782 got 150000
__main__.PQ0 on 300000 elapsed 1.58299994469 got 150000
__main__.PQueue on 300000 elapsed 2.14300012589 got 150000

BENCHMARKS FOR 400000

insertBench
__main__.PQPython23 on 400000 elapsed 16.2630000114 got 400000
__main__.PQ0 on 400000 elapsed 153.661000013 got 400000
__main__.PQueue on 400000 elapsed 24.7860000134 got 400000

mixBench
__main__.PQPython23 on 400000 elapsed 2.91400003433 got 200000
__main__.PQ0 on 400000 elapsed 1.8630001545 got 200000
__main__.PQueue on 400000 elapsed 2.73399996758 got 200000

BENCHMARKS FOR 500000

insertBench
__main__.PQPython23 on 500000 elapsed 20.1890001297 got 500000
__main__.PQ0 on 500000 elapsed 246.383999825 got 500000
__main__.PQueue on 500000 elapsed 30.1040000916 got 500000

mixBench
__main__.PQPython23 on 500000 elapsed 3.2650001049 got 250000
__main__.PQ0 on 500000 elapsed 2.35299992561 got 250000
__main__.PQueue on 500000 elapsed 3.32500004768 got 250000

BENCHMARKS FOR 1000000

insertBench
__main__.PQPython23 on 1000000 elapsed 43.0320000648 got 1000000
__main__.PQ0 on 1000000 elapsed 1376.39899993 got 1000000
__main__.PQueue on 1000000 elapsed 67.2970001698 got 1000000

mixBench
__main__.PQPython23 on 1000000 elapsed 6.93000006676 got 500001
__main__.PQ0 on 1000000 elapsed 4.8069999218 got 500001
__main__.PQueue on 1000000 elapsed 6.82999992371 got 500001

Jul 18 '05 #1
0 1418

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

38
by: Aaron W. LaFramboise | last post by:
Hello, I understand that an easy way to make the standard std::priority_queue stable is by including an integer stamp with each node that is incremented each time a new node is pushed into the...
6
by: Der Andere | last post by:
Are priority queues implemented in the STL in Visual Studio 6? If no, which is the easiest way to simulate them? Multisets? BTW: The container contains pointers to instances of a class. The...
1
by: Der Andere | last post by:
I posted this reaction in a thread quite far below so I fear people won't read it. I got stuck now for quite a while and just don't know what to try else. Thanks, Matthias > > Are priority...
1
by: Jim Strathmeyer | last post by:
So, I've been looking for a wrapper class for STL priority queues, and haven't been able to find one. (Websearching for info about the STL sure shows how much it's changed over the past few years.)...
5
by: Dan H. | last post by:
Hello, I have implemented a C# priority queue using an ArrayList. The objects being inserted into the priority queue are being sorted by 2 fields, Time (ulong) and Priority (0-100). When I...
3
by: eric.boissard | last post by:
Hello, I managed to implement the AStar algorithm, however I have some trouble using the priority queue, and the 'compare' function. Here is my 'Waypoint.h' header file: class Waypoint {...
8
by: vidishasharma | last post by:
Can somebody suggest good URL which contains code for merging of 2 or more priority queues in c#.
5
by: kidfiction | last post by:
Hello again, I was wondering if you could make priority queues with defined compare functions out of structs rather than objects. Currently I have this (with some things omitted: bool...
1
by: operatingsystem | last post by:
I need to generate such scheduler in operating system subject which satisfy below conditions...may i request u if anybody knows abt this plz help me out in this..topics.. Scheduler...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.