This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/21719] stdlib/msort : optimizing merge sort
- From: "ayush.m at samsung dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Thu, 06 Jul 2017 11:01:50 +0000
- Subject: [Bug libc/21719] stdlib/msort : optimizing merge sort
- Auto-submitted: auto-generated
- References: <bug-21719-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21719
--- Comment #2 from Ayush Mittal <ayush.m at samsung dot com> ---
(1) Worst case when elements are already sorted.
#define N 100000000
long a[N];
int cmpfn (const void * a, const void * b)
{
return ( *(long*)a - *(long*)b );
}
int main()
{
long i;
for (i=0;i<N;i++)
a[i]=i;
qsort(a, N, sizeof(long), cmpfn);
for (i=1;i<N;i++)
{
if(a[i]<a[i-1])
{
printf("Sorting failed\n");
break;
}
}
}
Tested on ARM:
Reading without patch :
# time ./qsort-test
real 0m22.011s
user 0m20.696s
sys 0m0.924s
Reading with patch :
# time ./qsort-test
real 0m3.797s
user 0m3.264s
sys 0m0.508s
--
You are receiving this mail because:
You are on the CC list for the bug.