Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^5: Fast data structure..!!!

by kyle (Abbot)
on Apr 15, 2008 at 17:03 UTC ( #680579=note: print w/replies, xml ) Need Help??


in reply to Re^4: Fast data structure..!!!
in thread Fast data structure..!!!

I ran this under Devel::NYTProf and found that this loop is the hot spot:

for(0 .. $tf) { my $last=vec ($wektor, $index++, 32); $pos{$docID}{$last}=$order; }

I changed it to this, following a suggestion from dvryaboy and also getting rid of the block completely:

$pos{$docID}{vec($wektor, $index++, 32)}=$order for 0 .. $tf;

That got somewhat faster.

I tried taking out the constant reference to $pos{$docID} like this:

$pos{$docID} ||= {}; my $did_ref = $pos{$docID}; $did_ref->{vec($wektor, $index++, 32)}=$order for 0 .. $tf;

...but that didn't make much difference to the hot loop, and it was more expensive outside the loop than the savings it got inside.

This is without really understanding what's going on, though. I wouldn't be surprised if what you're doing would benefit from just using a better algorithm.

Replies are listed 'Best First'.
Re^6: Fast data structure..!!!
by MimisIVI (Acolyte) on Apr 15, 2008 at 17:40 UTC
    Yes,this loop is the hot spot..Perhaps if i will change my algorithm will be the best way..

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://680579]
help
Chatterbox?
[marto]: see Super Search
[MidLifeXis]: Project Admin, a while ago: "No, I would prefer you didn't close that ticket yet confirming $vendor's support process yet. Continue to periodically check back to see if it has changed."...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (9)
As of 2017-01-19 12:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (170 votes). Check out past polls.