Re: Fastest way to read numbers in ascending order from array of i



In article <D7B9DB6A-6F65-4883-B26D-445171522739@xxxxxxxxxxxxx>,
Srini@xxxxxxxxxxxxxxxxxxxxxxxxx says...
The numbers get written by parallel message processing threads operation to a
preallocated mem location and once they all done the controller needs to
sequence them before it routes them for further processing. The max parallel
threads are 10. So we are looking at three to 10 numbers to read in their
ascending order.

In that case, it probably hardly matters. In fact, you _might_ be better
off writing your own simple sort (e.g. an insertion sort) simply because
most sort routines are really oriented toward dealing with larger
collections. OTOH, even a Quicksort (for one example) will often really
be a "modified Quicksort" that switches to something like an insertion
sort when the partitions get small enough -- and your ten items will
probably fall within what it considers "small enough". OTOH, using your
own routine you can still avoid a little bit of overhead of checking
whether you have that few of items to sort, so you might gain a little
-- but don't expect it to be much.

My initial advice would be to just dump the data into memory, call
std::sort, and chances are it'll be more than fast enough. If it's not,
check closely on what's taking the time -- chances are that it'll be
reading and writing the data rather than the sorting itself. In that
case, your main optimizations are going to be machine-specific, related
to things like ensuring you're making good use of the cache and
(possibly) pre-reading the data and such.

--
Later,
Jerry.

The universe is a figment of its own imagination.
.



Relevant Pages

  • Re: OT government
    ... WMD to Al Qaida? ... Do you suppose we could take chances on his NOT having poison gas ... take chances because we have perfect plans. ... Do you actually believe that sort of garbage? ...
    (rec.bicycles.tech)
  • Re: OT government
    ... Even though it was growing more and more evident that in order to maintain his position he was sooner or later going to have to deliver WMD to Al Qaida? ... Regardless of the BS about Iraq not getting along with Al Qaida the fact is that they were again and again trying to come to some sort of agreement. ... To read the people here you'd think that intelligence gathering is perfect and easy and that we always have sufficient knowledge of what's going on elsewhere behind closed doors and we NEVER have to take chances because we have perfect plans. ...
    (rec.bicycles.tech)
  • Re: {OT} Gov BJ vows to fight to his last breath.
    ... What sort of cuckoo-cloud land is he living in? ... He keeps demonstrating that he's living in a different ... are the same as the chances of me being a pregnant cheerleader. ... The chances of BlowJob being clean are about the same as his ability to pick ...
    (alt.autos.toyota)
  • Re: Good Friday
    ... Spent some time considering the chances of WASSEEMA in the 2.50. ... today's 7F on a track which should suit her front running style, ... Probably the best race of the daybut also the most difficult ... Anything from Meehans yard has to be respected in these sort ...
    (uk.sport.horseracing)
  • Re: Fitting a curve to a coin
    ... On Nov 17, 10:42 pm, Robert Israel ... please help me to sort out this, ... At any cost today, I've to get a solution for this, ... it has only two chances ...
    (sci.math)

Loading