[pure-lang-svn] SF.net SVN: pure-lang: [431] pure/trunk/examples/libor/date.pure
Status: Beta
Brought to you by:
agraef
From: <ye...@us...> - 2008-07-09 20:20:39
|
Revision: 431 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=431&view=rev Author: yes Date: 2008-07-09 13:20:47 -0700 (Wed, 09 Jul 2008) Log Message: ----------- made timex work with any number of arguments and return rounded ms cputime and elapsed time Modified Paths: -------------- pure/trunk/examples/libor/date.pure Modified: pure/trunk/examples/libor/date.pure =================================================================== --- pure/trunk/examples/libor/date.pure 2008-07-09 19:58:31 UTC (rev 430) +++ pure/trunk/examples/libor/date.pure 2008-07-09 20:20:47 UTC (rev 431) @@ -26,9 +26,14 @@ def venusinf = 1187409600;// 18th August 2007, 4am Venus inferior conjunction /******************************************************************************/ -// first a couple of functions generally useful in Pure: -// Albert Graef's timer function: returns cputime, value of (f onearg) -timex f x = (clock-t0)/CLOCKS_PER_SEC, res when t0 = clock; res = f x end; +// first some functions generally useful in Pure: +round n::double = int (n+0.5); +mstime = 1000.0*gettimeofday; +mscpu = 1000.0*clock/CLOCKS_PER_SEC; + +// timex returns a list: [ evaluated string argument, cputime, realtime ] +timex s::string = [(eval s), round (mscpu-c0), round (mstime-d0)] + when d0::double = mstime; c0::double = mscpu end; /* extended mod operator to work on doubles, so that int, bigint and double times can be conveniently used */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |