[BACK]Return to ts_timer.adb CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / PHC / Ada / System

File: [local] / OpenXM_contrib / PHC / Ada / System / ts_timer.adb (download)

Revision 1.1.1.1 (vendor branch), Sun Oct 29 17:45:34 2000 UTC (23 years, 6 months ago) by maekawa
Branch: PHC, MAIN
CVS Tags: v2, maekawa-ipv6, RELEASE_1_2_3, RELEASE_1_2_2_KNOPPIX_b, RELEASE_1_2_2_KNOPPIX, RELEASE_1_2_2, RELEASE_1_2_1, HEAD
Changes since 1.1: +0 -0 lines

Import the second public release of PHCpack.

OKed by Jan Verschelde.

with text_io,integer_io;            use text_io,integer_io;
with Timing_Package;                use Timing_Package;

procedure ts_timer is

-- DESCRIPTION :
--   Test of timing package on computing sums of natural numbers.
--   Do "time ts_timer" when running this program to see whether
--   the UNIX timer gives the same results as the printed times.

  n,m,acc : natural;
  timer,totaltimer : timing_widget;

begin
  new_line;
  put_line("Test of timer on computation of sums and products.");
  new_line;
  tstart(totaltimer);
  put("Give number of sums     : "); get(n);
  put("Give number of products : "); get(m);
  tstart(timer);
  acc := 0;
  for i in 1..n loop
    acc := acc + 1;
  end loop;
  tstop(timer);
  new_line;
  put("1 + 1 + .. + 1 : "); put(acc); new_line;
  print_times(timer,"calculating the sum");
  new_line;
  tstart(timer);
  acc := 1;
  for i in 1..m loop
    acc:= acc*acc;
  end loop;
  tstop(timer);
  put("1 * 1 * .. * 1 : "); put(acc); new_line;
  print_times(timer,"calculating the product");
  new_line;
  tstop(totaltimer);
  print_times(totaltimer,"the whole program");
  new_line;
end ts_timer;