i was having some very slow sorting problems using pfc::sort, which I couldnt explain, so i tried qsort_s instead.
Yes I am using 2007.02.04 SDK.
Results of my tests:
comp1, stabiliser:
profiler: compeid - 51547650 cycles (executed 98769 times, 521 average)
comp2, stabiliser (*):
profiler: compeid - 3693988890 cycles (executed 7147158 times, 516 average)
comp2, no stabiliser:
profiler: compeid - 61666740 cycles (executed 98769 times, 624 average)
comp2, q_sort_s, stabiliser (*):
profiler: compeid - 98539020 cycles (executed 168519 times, 584 average)
comp2, q_sort_s, no stabiliser:
profiler: compeid - 12529060 cycles (executed 18501 times, 677 average)
Here the profiler is counting/measuring the calls to the comparison function, across a few passes, and comp1 and comp2 are two different comparison funcs.
I marked the cases I am/was actually using with (*). In that case pfc::sort is ~37x slower (!)
this is comp1
static int g_compare_episodeid(const t_sort_entry & item1, const t_sort_entry & item2)
{
int ret = lstrcmpi(item1.episode, item2.episode);
return ret;
}
this is comp2
static int g_compare_episodeid(const t_sort_entry & item1, const t_sort_entry & item2)
{
int ret = lstrcmpi(item1.episode, item2.episode);
if (ret)
{
int l1 = item1.episode.length(1);
int l2 = item2.episode.length(1);
if (!l1 || !l2)
return l1 ? -1 : 1;
}
return ret;
}
and dataset is basically {"","","",.....,"","E06","",.....,""} (without quotes), size about 3000 entries.
I didnt spend too much time verifying the results/using better test method, but rather switching to qsort_s and the end sort result is the same and obviously much faster so I don't think I did anything wrong, but you never know. I am using VS2005 SP1 Vista Update.
Bye