Annotation of OpenXM_contrib/PHC/Ada/System/ts_timer.adb, Revision 1.1.1.1
1.1 maekawa 1: with text_io,integer_io; use text_io,integer_io;
2: with Timing_Package; use Timing_Package;
3:
4: procedure ts_timer is
5:
6: -- DESCRIPTION :
7: -- Test of timing package on computing sums of natural numbers.
8: -- Do "time ts_timer" when running this program to see whether
9: -- the UNIX timer gives the same results as the printed times.
10:
11: n,m,acc : natural;
12: timer,totaltimer : timing_widget;
13:
14: begin
15: new_line;
16: put_line("Test of timer on computation of sums and products.");
17: new_line;
18: tstart(totaltimer);
19: put("Give number of sums : "); get(n);
20: put("Give number of products : "); get(m);
21: tstart(timer);
22: acc := 0;
23: for i in 1..n loop
24: acc := acc + 1;
25: end loop;
26: tstop(timer);
27: new_line;
28: put("1 + 1 + .. + 1 : "); put(acc); new_line;
29: print_times(timer,"calculating the sum");
30: new_line;
31: tstart(timer);
32: acc := 1;
33: for i in 1..m loop
34: acc:= acc*acc;
35: end loop;
36: tstop(timer);
37: put("1 * 1 * .. * 1 : "); put(acc); new_line;
38: print_times(timer,"calculating the product");
39: new_line;
40: tstop(totaltimer);
41: print_times(totaltimer,"the whole program");
42: new_line;
43: end ts_timer;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>