ClojureClr time function

79 views
Skip to first unread message

Martynas Drobulis

unread,
Apr 4, 2017, 1:53:11 PM4/4/17
to Clojure Dev
Hello,

ClojureClr time retuns only full milliseconds

user=> (time (conj '() 1))
"Elapsed time: 0 msecs"
(1)

versus Clojure on JVM

user=> (time (conj '() 1))
"Elapsed time: 0.038176 msecs"
(1)


I've found that time fn in ClojureClr

https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure.Source/clojure/core.clj#L3843

Uses the RT.cs function StopStopwatch.

https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure/Lib/RT.cs#L3308

StopStopwatch returns only full milliseconds.


a simple fix like this

public static double StopStopwatch()
{
_stopwatch.Stop();
return _stopwatch.Elapsed.TotalMilliseconds;
}

would return whole and fractional milliseconds as a double.

The return type changes from long to double, so i'm not sure if it breaks any other code.

- Martynas

Alex Miller

unread,
Apr 4, 2017, 1:57:22 PM4/4/17
to Clojure Dev
Hey Martynas,

It's probably best to discuss this on the clojure-clr mailing list:


Alex
Reply all
Reply to author
Forward
0 new messages