in reply to Re: Re: Re: Re: Re: looking for a Priority Queue
in thread looking for a Priority Queue
Hi you are of course correct and incorrect. The algorithm implemented by this module (now Heap::Priority on CPAN - when it gets listed) assumes that the item count >> number of priority levels.
I have improved the priority level sort efficiency so that all that happens is that a new priority level is sorted to its correct place which is O(n) rather than the less efficient way it was done.
As it currently stands it will add() and pop() 100,000 items into 100 different levels in 9 seconds or into 1000 levels in 40 seconds. Yes that is definitely a geometric decay as the number of priority levels go up....
use Heap::Priority; my $n = 100000; my $start = time; my $h = new Heap::Priority; $h->add($_, $_%1000) for 1..$n; $h->pop for 1..$n; print "Did $n in ", time - $start, " seconds"; __DATA__ Did 100000 in 40 seconds
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: Re: Re: looking for a Priority Queue
by educated_foo (Vicar) on May 07, 2002 at 16:08 UTC |