S. Fisher wrote:
--- Marco van de Voort <[EMAIL PROTECTED]> wrote:

http://shootout.alioth.debian.org/gp4/benchmark.php?test=all&lang=all

The reason is that D's mean degraded from 1.40 to 1.43.  I wonder how
that could happen.
They change often. Clean is also quite variable. I assume the differences
are simply in the magnitude of the uncertainty of the measuring.

I submitted this regex-dna program on 2007-10-31.  It's still in limbo:
neither accepted nor rejected.

{ The Computer Language Benchmarks Game
  http://shootout.alioth.debian.org

  contributed by Steve Fisher

  compile with
  fpc -O3 regex-dna.pp
}

uses regexpr, strutils;

function replace_matches( const target: pchar;  const repl: pchar;
                const str: ansistring;  var dest: ansistring ): longint;
var
  engine : tRegexprEngine;
  substr : ansistring;
  count, index, size : longint;
begin
  if not GenerateRegExprEngine( target, [], engine) then
  begin
    writeln( 'Failed to generate regex. engine for "',target,'".' );
    halt(1)
  end;
  count := 0;
  dest := '';
  substr := str;
  while length(substr) > 0 do
  begin
    if RegExprPos(engine, pchar(substr), index, size ) then
    begin
      count += 1;
      dest += ansiLeftStr( substr, index) + repl;
      substr := ansiRightStr(substr,length(substr)-index-size);
    end
    else
      break
  end;
  DestroyRegExprEngine( engine );
  dest += substr;
  exit(count)
end;

function count_matches( target: pchar; const str: ansistring ): longint;
var
  engine : tRegexprEngine;
  substr : ansistring;
  count, index, size : longint;
begin
  if not GenerateRegExprEngine( target, [ref_caseinsensitive], engine) then
  begin
    writeln( 'Failed to generate regex. engine for "',target,'".' );
    halt(1)
  end;

For this benchmark you don't need extra unneeded code for checking conditions. If the test fails it fails, so don't worry on errors

Marc



_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to