Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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.


Comment on Re^5: Fast data structure..!!!
Select or Download Code
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (10)
As of 2014-07-29 06:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (211 votes), past polls