Open letter to Ian Collins



Hi Ian

In the c++ newsgroup you asked me for an example of the ccl performance
It was something with building a huge list, then sorting it, if I remember correctly...

I have built this example code:

#include <stdlib.h>
#include "containers.h"
#define N 10000000
int main(void)
{
List *L1;
size_t i,d;
long long sum=0,newSum=0;
Iterator *it;
int *pint;

L1 = iList.Create(sizeof(int));
iList.UseHeap(L1,NULL);
for (i=0; i<N;i++) {
d = rand();
sum += d;
iList.Add(L1,&d);
}
iList.Sort(L1);
it = iList.NewIterator(L1);
for (pint = it->GetFirst(it); pint; pint = it->GetNext(it)) {
newSum += *pint;
}
if (sum != newSum)
printf("Failed\n");
else printf("Sum = %lld\n",sum);
iList.Finalize(L1);
}

This creates a list, then fills it with 10 million random integers,
then sorts it and verifies that all the data is still there by
accessing all elements of the list with an iterator.

Can you please send me an equivalent C++program?

Thanks
.



Relevant Pages

  • Re: Open letter to Ian Collins
    ... In the c++ newsgroup you asked me for an example of the ccl performance ... int main ... if (sum!= newSum) ... accessing all elements of the list with an iterator. ...
    (comp.lang.c)
  • Open letter to Ian Collins
    ... for an example of the ccl performance ... It was something with building a huge list, then sorting it, if I ... if (sum!= newSum) { ...
    (comp.lang.c)
  • Re: migration thread and active_load_balance
    ... > a different iterator I wrote. ... > add a few variables to struct rq and struct cfs_rq. ... static int migration_thread ... int cpu = data; ...
    (Linux-Kernel)
  • Re: Performance of hand-optimised assembly
    ... Why not use unsigned for sum in the test harness? ... int is better yet because the output will then be same across machines. ... gcc -O3 seems ... but taking an average by eye my best asm version was *slower* than ...
    (comp.lang.c)
  • Re: [PATCH] input: Introduce light-weight contact tracking
    ... seems the patch was damaged somehow. ... static int illegal(int nslot, int npos, unsigned x) ... int i, j, sum; ...
    (Linux-Kernel)