Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re: Re: Re: Re: Confirming what we already knew

by l2kashe (Deacon)
on Mar 05, 2003 at 14:50 UTC ( [id://240588]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Re: Confirming what we already knew
in thread Confirming what we already knew

You might be able to achieve a huge performance gain by taking your algorithms and memoizing them. I.e
my %multiply = (); $str = "$num1 $num2"; if (!$multiply{$str}) { $result = $num1 * $num2; $multiply{$str) = "$result"; } else { $result = "$multiply{$str}"; } # use result to do something else below
You could even turn this into a sub function, which takes a string as an argument, shifts it as it goes, determines what to do with the different expressions on the line, and then returns the final result. Thinking about that though.. You would need to add logic to deal with precedence, and parentheses. Also it would be very expensive to start, but once you are through a fair portion of your data, it will really help

This is probably a very poor example, and could be cleaned/optimized, but you see the point I hope. Floating point math is always leaps and bounds slower then interger math. On top of that you moved from a windows machine to a FreeBSD machine. The kernel architecture, memory management, threading mechanisms, as well as application overhead all play massive roles in how your code will perform, especially in regards to loops such as you are talking about.

Also as long as the data sets do not rely on each other, you could take all your data, parse it, store it in a hash or array, then take slices of those structures and fork off seperate processes which can do the computations in parallel, and then collect the results from files, or even share memory space, and have them all report back when they are done if you have ithreads enabled, and know how to use them.

I really am interested to see your code, much like other monks. I have started a few threads about speed, and squeezing the last bit I can out of perl. I've received great help and optimizations, which have also allowed me to peer a little deeper into how perl works and what it likes to see. It really does worry me, just like the other monks have stated, that your perl code looks like your C code. You could be missing out on some really great stuff there.

O well just my 2 cents..

/* And the Creator, against his better judgement, wrote man.c */

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Confirming what we already knew
by AssFace (Pilgrim) on Mar 05, 2003 at 17:15 UTC
    in regards to what system it is running on - I have run the Perl code on a win2K P4 2G box, a WinXP Home Athlon Mobile 1G box, a dual PIII 667 RH8 Linux box (didn't do anything to take into account the dual processors, so it just ran effectively on one), a PII 300 RH Linux box, and they all seem to scale based on the processor speed - although the Athlon Mobile 1G seemed to be slightly faster than what its rating would make one think - but that is what AMD is known for (the P4 2G runs it in around 195 seconds and the Athlon Mobile 1G runs it in 300 seconds).

    Things are kind of busy at work right now - if I can get a chance - I will try to strip out parts of my code that I am wary of (what the data looks like and the comments) and then I will try to post it here later - maybe tonight if I can get to it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://240588]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-23 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found