[fpc-pascal] Re: Shootout: k-nucleotide implementation (was: Which programming language is fastest?)

Lukasz Sokol el.es.cr at gmail.com
Mon May 9 12:25:11 CEST 2011


On 09/05/2011 11:06, Lukasz Sokol wrote:
> On 08/05/2011 21:25, Bernd wrote:
>> Ok, I have looked at the example that was the slowest: 5 times slower than gcc.
>>
>> k-nucleitide: http://shootout.alioth.debian.org/u32/benchmark.php?test=knucleotide&lang=all
>>
>> The C++ code is giving me headaches from only looking at it. I am
>> still not sure what the hell they have done (or cheated) to reach this
>> speed. Looking at the Python example explains what the benchmark
>> actually does in less than a screenpage.
> 
> Mmm..
> 4.45s to complete and log all make actions (C++ gnu g++)
> 0.11s to complete and log all make actions (Pascal Free Pascal)
> 
> we _are_ _compiling_ it faster ;)
> 
> and
> 132,656 kB vs 127,684 kB memory, we're actually _better_ than them ;)
> and 2383 vs 2106 code length (well they're better here).
> 
> Maybe 
> /usr/local/src/fpc-2.4.2.i386-linux/bin/fpc -FuInclude/fpascal -XXs -Oppentiumm -Cppentiumm -O3 -Cfsse2  -oFPASCAL_RUN knucleotide.fpascal-2.pas 
> 
> the command line also is the answer ? (is the Q6600 64bit ?)
> also c++ code sports things like cpu affinity, while we don't...
> or they try to _parallelize_ it behind the machines' back ?
Oh yeah, look:

(c++ code)
Queue workQueue;
  Worker *workers = new Worker[cpus.count];
  for ( u32 i = 0; i < cpus.count; i++ )
    workers[i].start( &workQueue, block );
  for ( u32 i = 0; i < cpus.count; i++ )
    workers[i].join();

They do it in workqueues...

also they read 4 bytes characters input 

void addline( const char *buffer, int bytes )
[...]
u8 *out = (u8 *)( data + count / 4 );
// 00000dd0:00000cc0-00000bb0:00000aa0 -> ddccbbaa

-> they take advantage of unicode or whatever mcbs the shell makes them do ?

I think we spend too much time&effort adding data to buffer

(procedure main)
[...]
  while not eof do begin
     readln(s);
     if (s[1] <> '>') and (s[1] <> ';') then begin
       len:=length(s);
       if (bufferptr+len+1)>buffersize then  begin
         inc(buffersize,buffersize);
         reallocmem(buffer,buffersize);
       end;
       move (s[1],buffer[bufferptr],len);
       inc(bufferptr,len);
     end;
   end;

instead of getting it processed on the fly;

(this just 5 min I had to spare, now I have to go ;)
L.

> 
> Hard to say.
> 
> (Not that I know much about c++ generally)
> :)
> Lukasz
> [...]
> 
>> Bernd
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 





More information about the fpc-pascal mailing list