Re: Fastest way to read numbers in ascending order from array of i
- From: Jerry Coffin <jcoffin@xxxxxxxxx>
- Date: Mon, 7 Aug 2006 17:28:45 -0600
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.
.
- References:
- Re: Fastest way to read numbers in ascending order from array of integ
- From: Jerry Coffin
- Re: Fastest way to read numbers in ascending order from array of integ
- Prev by Date: Re: Fastest way to read numbers in ascending order from array of integ
- Next by Date: Re: Fastest way to read numbers in ascending order from array of i
- Previous by thread: Re: Fastest way to read numbers in ascending order from array of integ
- Next by thread: Re: Fastest way to read numbers in ascending order from array of i
- Index(es):
Relevant Pages
|
Loading