Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #22241

Re: Open letter to Ian Collins

From jacob navia <jacob@spamsink.net>
Newsgroups comp.lang.c
Subject Re: Open letter to Ian Collins
Date 2012-06-14 04:00 +0200
Organization lccwin
Message-ID <jrbgkb$vva$1@speranza.aioe.org> (permalink)
References <jprl29$ifd$1@speranza.aioe.org> <a2dkjvF7faU2@mid.individual.net> <jpsl62$h39$1@speranza.aioe.org> <a2e8hgF7faU3@mid.individual.net> <4FD93D9B.7012@mindspring.com>

Show all headers | View raw


Le 14/06/12 03:25, pete a écrit :
> Ian Collins wrote:
>>
>> On 05/27/12 07:30 PM, jacob navia wrote:
>>> Le 27/05/12 05:16, Ian Collins a écrit :
>>>> On 05/27/12 10:22 AM, jacob navia wrote:
>>>>> 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:
>>>>>
>>>> <snip>
>>>>
>>>> I get a segv when I run the example.
>>>> Running in dbx with access checking
>>>> enabled shows:
>>>
>>> I corrected that yesterday.
>>> When you asked me gthis example I was in the
>>> middle of a reorganization of heap.c. Look at the latest update
>>
>> OK,
>> I thought I had but I didn't notice wget saving the file as cc.zip.1
>> rather than overwriting the version I downloaded earlier in the week.
>>
>> Anyway I ran ran the code
>> built with Sun Studio rather than gcc because
>> it runs quite a bit faster.  As I expected, the big difference was in
>> sorting:
>>
>> ccl version:
>>
>> To sort     85.6384S
>>
>> C++ version (std::list.sort()):
>>
>> To sort     18.7927S
>>
>> Iteration was closer:
>>
>> To access    2.80655S (ccl)
>> To access    1.82896S
>
> /*
> ** Would you please run this program
> ** and let me know what the output is?
> ** I'm of the opinion that the QSORT function
> ** which is currently in listgen.c, at
> ** http://code.google.com/p/ccl/downloads/detail?name=ccl.zip&can=2&q=
> ** has approximately zero chance of correctly sorting
> ** a data set of as many as 10000000 psuedorandom keys.
> */
> #include<stdlib.h>
>
> #include "containers.h"
> #include "intlist.h"
>
> #define N 10000000
>
> int
> main(void)
> {
>      intList *L1;
>      size_t i;
>      int d;
>      long unsigned sum=0,newSum=0;
>      Iterator *it;
>      int *pint, last_pint;
>
>      L1 = iintList.Create(sizeof(int));
>      iintList.UseHeap(L1,NULL); // Use specialized Heap
>      // Add N random numbers to the integer list
>      for (i=0; i<N;i++) {
>          d = rand();
>          sum += d;
>          iintList.Add(L1,d);
>      }
>      // Sort it
>      iintList.Sort(L1);
>      // Go through the sorted list using an iterator
>      it = iintList.NewIterator(L1);
>      i=0;
>      pint = it->GetFirst(it);
>      while (pint != NULL) {
>          last_pint = *pint;
>          newSum += last_pint;
>          pint = it->GetNext(it);
>          if (pint != NULL&&  last_pint>  *pint) {
>              puts("\n\nThe data is not sorted.\n\n");
>              iintList.Finalize(L1);
>              exit(EXIT_SUCCESS);
>          }
>      }
>      // Verify that both sums are identical
>      if (sum != newSum) {
>          printf("Failed\n");
>      } else {
>          printf("Sum = %lu\n",sum);
>      }
>      // Destroy the list
>      iintList.Finalize(L1);
>      return 0;
> }
>

Hi Pete

The output is:
Sum = 10737818730605039

Maybe because I incorporated the changes you proposed to the quick sort
template after the last discussion.

You get another output? Have you tried with the latest sources?

Thanks for your help.

jacob

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 00:22 +0200
  Re: Open letter to Ian Collins Ike Naar <ike@sverige.freeshell.org> - 2012-05-26 22:36 +0000
    Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 01:13 +0200
      Re: Open letter to Ian Collins Barry Schwarz <schwarzb@dqel.com> - 2012-05-26 16:53 -0700
    Re: Open letter to Ian Collins Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-05-26 16:41 -0700
      Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-26 22:43 -0400
  Re: Open letter to Ian Collins Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-05-26 15:41 -0700
    Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 01:14 +0200
  Re: Open letter to Ian Collins MelissA <melis@a.com> - 2012-05-27 00:52 +0200
  Re: Open letter to Ian Collins Stephen Sprunk <stephen@sprunk.org> - 2012-05-26 20:40 -0500
    Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 09:32 +0200
      Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-27 07:18 -0400
  Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-27 14:24 +1200
    Re: Open letter to Ian Collins "BartC" <bc@freeuk.com> - 2012-05-27 10:36 +0100
      Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-27 22:33 +1200
        Re: Open letter to Ian Collins "BartC" <bc@freeuk.com> - 2012-05-27 12:25 +0100
          Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-28 07:17 +1200
      Re: Open letter to Ian Collins Ike Naar <ike@sverige.freeshell.org> - 2012-05-27 13:03 +0000
  Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-27 15:16 +1200
    Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 09:30 +0200
      Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-27 20:56 +1200
        Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 11:12 +0200
          Re: Open letter to Ian Collins Ian Collins <ian-news@hotmail.com> - 2012-05-27 21:22 +1200
            Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-27 07:15 -0400
            Re: Open letter to Ian Collins Keith Thompson <kst-u@mib.org> - 2012-05-27 07:49 -0700
              Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-27 13:55 -0400
                Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 22:24 +0200
                Re: Open letter to Ian Collins "BartC" <bc@freeuk.com> - 2012-05-27 22:09 +0100
                Re: Open letter to Ian Collins Keith Thompson <kst-u@mib.org> - 2012-05-27 14:33 -0700
                Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-27 17:49 -0400
                Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-27 17:31 -0400
                Re: Open letter to Ian Collins Philip Lantz <prl@canterey.us> - 2012-05-28 01:38 -0700
                Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-05-28 08:18 -0400
        Re: Open letter to Ian Collins "BartC" <bc@freeuk.com> - 2012-05-27 15:46 +0100
        Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-06-13 21:25 -0400
          Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-06-13 21:52 -0400
          Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-06-14 04:00 +0200
            Re: Open letter to Ian Collins pete <pfiland@mindspring.com> - 2012-06-14 00:04 -0400
  Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-27 09:42 +0200
  Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-28 12:39 +0200
    Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-28 21:44 +0200
      Re: Open letter to Ian Collins jacob navia <jacob@spamsink.net> - 2012-05-29 09:46 +0200
        Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-29 10:06 +0200
          Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-29 10:37 +0200
            Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-29 10:58 +0200
              Re: Open letter to Ian Collins "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2012-05-29 11:34 +0200
              Re: Open letter to Ian Collins Malcolm McLean <malcolm.mclean5@btinternet.com> - 2012-05-29 03:02 -0700
      Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-29 09:59 +0200
      Re: Open letter to Ian Collins "io_x" <a@b.c.invalid> - 2012-05-29 20:09 +0200
  Re: Open letter to Ian Collins "Sarah Wren" <swreb@ameritech.net> - 2012-05-29 01:40 -0600

csiph-web