Skip to content

Commit

Permalink
Merge pull request #2440 from triska/statistics
Browse files Browse the repository at this point in the history
ADDED: Preliminary support for statistics/2.
  • Loading branch information
mthom authored Jul 7, 2024
2 parents 5f30c95 + 0005dca commit 9027126
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/lib/time.pl
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Written 2020-2023 by Markus Triska (triska@metalevel.at)
Written 2020-2024 by Markus Triska (triska@metalevel.at)
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)).
Expand Down Expand Up @@ -91,7 +97,16 @@
).


% '$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).

Expand Down

0 comments on commit 9027126

Please sign in to comment.