comp.lang.ada
 help / color / mirror / Atom feed
From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Re: Benchmarking
Date: Mon, 10 Aug 2009 13:23:04 -0700 (PDT)
Date: 2009-08-10T13:23:04-07:00	[thread overview]
Message-ID: <9c40a22f-1b76-4feb-b707-4571123de70d@z28g2000vbl.googlegroups.com> (raw)
In-Reply-To: cbfd26ce-1c87-4606-8dd3-f413d2cbda89@n2g2000vba.googlegroups.com

Hello!
Here is the generic Timing procedure I'm using for "shooting-out" a
bit. The instanciation for one test holds then in one line:
  with Timing, Fasta_O, Fasta; procedure Fasta_Timing is new Timing
( 100, "Fasta 2005", "Fasta 2009", Fasta_O, Fasta);
HTH
Gautier

-- Timing of two algorithms P1, P2 (wall clock time).
-- P1 and P2 are run "runs" times (+1 as "tour de chauffe").

generic
  runs: Positive;
  n1, n2: String;
  with procedure P1;
  with procedure P2;
procedure Timing;

with Ada.Text_IO;                       use Ada.Text_IO;
with Ada.Calendar;                      use Ada.Calendar;
with Ada.Numerics.Float_Random;         use Ada.Numerics.Float_Random;

procedure Timing is
  a1,z1,a2,z2: Time;
  f, t1s,t2s: Long_Float;
  package LFIO is new Ada.Text_IO.Float_IO(Long_Float); use LFIO;
  gen: Generator;
begin
  Put_Line("Heating..."); -- Skip (most of) cache effects
  P1;
  P2;
  -- Now we start for real:
  t1s:= 0.0;
  t2s:= 0.0;
  Reset(gen);
  for run in 1..runs loop
    Put_Line(Standard_Error, "========= Run" & run'img & " of" &
runs'img);
    if Random(gen) > 0.5 then
      a1:= Clock;  P1;  z1:= Clock;
      a2:= Clock;  P2;  z2:= Clock;
    else
      a2:= Clock;  P2;  z2:= Clock;
      a1:= Clock;  P1;  z1:= Clock;
    end if;
    Put_Line(Standard_Error, "Time in seconds for...");
    Put(Standard_Error, "P1 ("&n1&"): " & Duration'Image(z1-a1));
    Put(Standard_Error, " -- average so far: ");
    Put(Standard_Error, t1s / Long_Float(run),0,5,0);
    New_Line(Standard_Error);
    Put(Standard_Error, "P2 ("&n2&"): " & Duration'Image(z2-a2));
    Put(Standard_Error, " -- average so far: ");
    Put(Standard_Error, t2s / Long_Float(run),0,5,0);
    New_Line(Standard_Error);
    f:= Long_Float(z2-a2) / Long_Float(z1-a1);
    Put(Standard_Error, "\--> time factor (T2/T1): "); Put
(Standard_Error, f,0,5,0);
    t1s:= t1s + Long_Float(z1-a1);
    t2s:= t2s + Long_Float(z2-a2);
    Put(Standard_Error, " -- average so far: ");
    Put(Standard_Error, t2s / t1s,0,5,0);
    New_Line(Standard_Error);
  end loop;
  -- Put("[press return]"); Skip_Line;
end;



      parent reply	other threads:[~2009-08-10 20:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-10 15:39 Benchmarking ravege
2009-08-10 17:32 ` Benchmarking Yannick Duchêne Hibou57
2009-08-10 18:17 ` Benchmarking Georg Bauhaus
2009-08-10 20:23 ` Gautier write-only [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox