report time with "s" instead of "seconds", in analogy to time(1)

This addresses https://github.com/mthom/scryer-prolog/pull/1131#issuecomment-988670049 .
This commit is contained in:
Markus Triska
2021-12-08 16:13:54 +01:00
parent 2eae6b4be7
commit 12c561cee0

View File

@@ -120,32 +120,33 @@ report_time(ID) :-
'$cpu_now'(T), '$cpu_now'(T),
Time is T - T0, Time is T - T0,
( bb_get('$first_answer', true) -> ( bb_get('$first_answer', true) ->
format(" % CPU time: ~3f seconds~n", [Time]) Pre = " ", Post = ""
; format("% CPU time: ~3f seconds~n ", [Time]) ; Pre = "", Post = " "
). ),
format("~s% CPU time: ~3fs~n~s", [Pre,Time,Post]).
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
?- time((true;false)). ?- time((true;false)).
%@ % CPU time: 0.006 seconds %@ % CPU time: 0.006s
%@ true %@ true
%@ ; % CPU time: 0.001 seconds %@ ; % CPU time: 0.001s
%@ false. %@ false.
:- time(use_module(library(clpz))). :- time(use_module(library(clpz))).
%@ % CPU time: 3.711 seconds %@ % CPU time: 3.711s
%@ true. %@ true.
:- time(use_module(library(lists))). :- time(use_module(library(lists))).
%@ % CPU time: 0.006 seconds %@ % CPU time: 0.006s
%@ true. %@ true.
?- time(member(X, "abc")). ?- time(member(X, "abc")).
%@ % CPU time: 0.005 seconds %@ % CPU time: 0.005s
%@ X = a %@ X = a
%@ ; % CPU time: 0.000 seconds %@ ; % CPU time: 0.000s
%@ X = b %@ X = b
%@ ; % CPU time: 0.000 seconds %@ ; % CPU time: 0.000s
%@ X = c %@ X = c
%@ ; % CPU time: 0.000 seconds %@ ; % CPU time: 0.000s
%@ false. %@ false.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */