From: Markus Triska Date: Sat, 6 Jul 2024 09:15:30 +0000 (+0200) Subject: ADDED: Preliminary support for statistics/2. X-Git-Tag: v0.10.0~129^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=0005dcaacb197e55d7cf6ffa40aa74e3260a4b76;p=scryer-prolog.git ADDED: Preliminary support for statistics/2. This is needed for benchmarking library(reif) and its newly provided goal expansion (#2433). It partly addresses #321. --- diff --git a/src/lib/time.pl b/src/lib/time.pl index 5fa94c40..4ec55e03 100644 --- a/src/lib/time.pl +++ b/src/lib/time.pl @@ -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)). @@ -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).