]> Repositorios git - scryer-prolog.git/commitdiff
ADDED: Preliminary support for statistics/2.
authorMarkus Triska <[email protected]>
Sat, 6 Jul 2024 09:15:30 +0000 (11:15 +0200)
committerMarkus Triska <[email protected]>
Sat, 6 Jul 2024 09:33:02 +0000 (11:33 +0200)
This is needed for benchmarking library(reif) and its newly provided
goal expansion (#2433).

It partly addresses #321.

src/lib/time.pl

index 5fa94c40ee6bd7365f59bc9f1fea5bde3c669a21..4ec55e0392325522a7cd640ac64f9251613e15b4 100644 (file)
@@ -1,12 +1,18 @@
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-   Written 2020-2023 by Markus Triska ([email protected])
+   Written 2020-2024 by Markus Triska ([email protected])
    Part of Scryer Prolog.
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 
 /** This library provides predicates for reasoning about time.
 */
 
-:- module(time, [max_sleep_time/1, sleep/1, time/1, current_time/1, format_time//2]).
+:- module(time, [max_sleep_time/1,
+                 sleep/1,
+                 time/1,
+                 current_time/1,
+                 format_time//2,
+                 statistics/2
+                ]).
 
 :- use_module(library(format)).
 :- use_module(library(iso_ext)).
@@ -91,7 +97,16 @@ sleep(T) :-
     ).
 
 
-% '$cpu_now' can be replaced by statistics/2 once that is implemented.
+%% statistics(?Keyword, ?List)
+%
+%  Preliminary support for statistics/2, yielding timing information.
+%  The only supported `Keyword` is `runtime`. The first element of
+%  `List` is the CPU time in milliseconds, the second element is
+%  currently not supported.
+
+statistics(runtime, [T,unsupported]) :-
+        '$cpu_now'(T0),
+        T is T0*1000.
 
 :- meta_predicate time(0).