Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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 lurking in the Monastery: (9)
As of 2014-12-26 04:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls