File: common.pl

package info (click to toggle)
gprolog 1.4.5.0-3
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 7,924 kB
  • sloc: ansic: 55,584; perl: 18,501; sh: 3,401; makefile: 1,114; asm: 20
file content (59 lines) | stat: -rw-r--r-- 722 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% A generic benchmark interface

q :-
	(   get_count(Count)
        ;   Count = 1
        ),
	!,
	do_bench(Count).


do_bench(Count) :-
	get_cpu_time(T1),
	iterate_bench(Count),
	get_cpu_time(T2),
	Time is T2-T1,
	TimeIt is Time // Count,
	write(TimeIt),
	write(' msec per iter, '),
	write(Count),
	write(' iters, total time : '),
	write(Time),
	write(' msec'),
	nl.

iterate_bench(Count) :-
	rep(Count, Last),
	ShowResult = Last,
	exec_bench(ShowResult),
	Last = true.


exec_bench(ShowResult) :-
	benchmark(ShowResult),
	!.


rep(1, true):-
	!.

rep(_, false).

rep(N, Last) :-
	N1 is N - 1,
	rep(N1, Last).


/*
 * this file should define:
 * get_count/1
 * get_cpu_time/1
 * and launch q/0
 */

:- include(hook).