From 12c561cee0b71140950c3dc4c3dda8e98dc7309d Mon Sep 17 00:00:00 2001 From: Markus Triska Date: Wed, 8 Dec 2021 16:13:54 +0100 Subject: [PATCH] report time with "s" instead of "seconds", in analogy to time(1) This addresses https://github.com/mthom/scryer-prolog/pull/1131#issuecomment-988670049 . --- src/lib/time.pl | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/lib/time.pl b/src/lib/time.pl index 6e3aa73d..56e31fae 100644 --- a/src/lib/time.pl +++ b/src/lib/time.pl @@ -120,32 +120,33 @@ report_time(ID) :- '$cpu_now'(T), Time is T - T0, ( bb_get('$first_answer', true) -> - format(" % CPU time: ~3f seconds~n", [Time]) - ; format("% CPU time: ~3f seconds~n ", [Time]) - ). + Pre = " ", Post = "" + ; Pre = "", Post = " " + ), + format("~s% CPU time: ~3fs~n~s", [Pre,Time,Post]). /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ?- time((true;false)). -%@ % CPU time: 0.006 seconds +%@ % CPU time: 0.006s %@ true -%@ ; % CPU time: 0.001 seconds +%@ ; % CPU time: 0.001s %@ false. :- time(use_module(library(clpz))). -%@ % CPU time: 3.711 seconds +%@ % CPU time: 3.711s %@ true. :- time(use_module(library(lists))). -%@ % CPU time: 0.006 seconds +%@ % CPU time: 0.006s %@ true. ?- time(member(X, "abc")). -%@ % CPU time: 0.005 seconds +%@ % CPU time: 0.005s %@ X = a -%@ ; % CPU time: 0.000 seconds +%@ ; % CPU time: 0.000s %@ X = b -%@ ; % CPU time: 0.000 seconds +%@ ; % CPU time: 0.000s %@ X = c -%@ ; % CPU time: 0.000 seconds +%@ ; % CPU time: 0.000s %@ false. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -- 2.54.0