
time(P) :-
	tell('/dev/null'),
	cputime(Start),
	P,
	cputime(Finish),
	told,
	Total is Finish - Start,
	Nsecs is Total / 50,
	LeftOver is Total mod 50 * 100 / 50,
	(LeftOver < 10 -> Sep = '.0' | Sep = '.'),
	print('Time = ', Nsecs, Sep, LeftOver, ' secs').


long_time(N, P) :-
	retractall(timer(X)),
	assert(timer(N)),
	cputime(Start),
	repeat,
	P,
	retract(timer(X)),
	X1 is X - 1,
	assert(timer(X1)),
	X1 == 0,
	cputime(Finish),
	Total is Finish - Start,
	Nsecs is Total / 50,
	LeftOver is Total mod 50 * 100 / 50,
	(LeftOver < 10 -> Sep = '.0' | Sep = '.'),
	print('Time = ', Nsecs, Sep, LeftOver, ' secs').

private([timer])!
