in reply to Re^2: Sharing statics variable between Threads
in thread Sharing statics variable between Threads
Your code is full of silly inefficiencies; like these 3 calculations:
$data->{magX}[ $dataIdx ] * cos( $data->{phX}[ $dataIdx ] ) $data->{magY}[ $dataIdx ] * cos( $data->{phY}[ $dataIdx ] ) $data->{magZ}[ $dataIdx ] * cos( $data->{phZ}[ $dataIdx ] )
being performed for all 50 million $data points; and all 50 million being repeated for every one of the "thousands" of $center points. That's 3 * "thousands" * "50.000.000" of redundant, repeated calculations.
Also, whilst I won't pretend to fully understand your code in isolation of what TransfNorVec(), coordSystTransf() & Check() subs do, it seems fairly clear you are checking a bunch of 3D points against another bunch of 3D points and accumulating statistics about how many of the former are within some distance of some of the latter.
And you are going about it by brute force.
With a clearer picture of the data (in $data (what an awful name) and $center), it ought to be possible to order (sort or structure -- perhaps 3-dimensionally) them, so that for any given $input only a small subset of the 'thousands by millions' of comparisons (and associated calculations) need be done.
For example, if the point's X value is 50 and the radius of the compare is 5, there is no point in comparing against any other point who's X-value is outside of 45 thru 55. Sub-setting the larger range early could save billions of calculations, comparisons, object constructions and function calls.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Sharing statics variable between Threads
by rodeo (Initiate) on Sep 02, 2013 at 11:37 UTC | |
by BrowserUk (Patriarch) on Sep 02, 2013 at 11:59 UTC |