Skip to content

Commit 587fe69

Browse files
committed
ADDED: Preliminary support for statistics/2.
This is needed for benchmarking library(reif) and its newly provided goal expansion (mthom#2433). It partly addresses mthom#321.
1 parent 5f30c95 commit 587fe69

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/lib/time.pl

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2-
Written 2020-2023 by Markus Triska (triska@metalevel.at)
2+
Written 2020-2024 by Markus Triska (triska@metalevel.at)
33
Part of Scryer Prolog.
44
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
55

66
/** This library provides predicates for reasoning about time.
77
*/
88

9-
:- module(time, [max_sleep_time/1, sleep/1, time/1, current_time/1, format_time//2]).
9+
:- module(time, [max_sleep_time/1,
10+
sleep/1,
11+
time/1,
12+
current_time/1,
13+
format_time//2,
14+
statistics/2
15+
]).
1016

1117
:- use_module(library(format)).
1218
:- use_module(library(iso_ext)).
@@ -91,7 +97,16 @@
9197
).
9298

9399

94-
% '$cpu_now' can be replaced by statistics/2 once that is implemented.
100+
%% statistics(?Keyword, ?List)
101+
%
102+
% Preliminary support for statistics/2, yielding timing information.
103+
% The only supported `Keyword' is `runtime`. The first element of
104+
% `List` is the determined value, the second element is currently not
105+
% supported.
106+
107+
statistics(runtime, [T,unsupported]) :-
108+
'$cpu_now'(T0),
109+
T is T0*1000.
95110

96111
:- meta_predicate time(0).
97112

0 commit comments

Comments
 (0)