Is it possible to cast the Elapsed Time function to Integer?

I have the following function:

(def elapsedtime (with-out-str (time (run-my-function))))

and I was wondering if is possible to store only the integer value of the time, as I can only store a String at the moment....

Any suggestion? Thanks a lot


So I did use this:
  (defmacro nsecs
  `(let [start# (. System (nanoTime))]
     (- (. System (nanoTime)) start#)))

And then modified this:

(def elapsedtime (nsecs (run-my-function argument1 argument2)))

but doesn't work, what am I doing wrong?

"Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Wrong number of args (1) passed to: main$fn--105$nsecs"


Instead of extracting this value from a string, let's take a look at the source of the time macro.

(defmacro time
  "Evaluates expr and prints the time it took.  Returns the value of expr."
  {:added "1.0"}
  `(let [start# (. System (nanoTime))
         ret# ~expr]
     (prn (str "Elapsed time: "
               (/ (double (- (. System (nanoTime)) start#)) 1000000.0) " msecs"))

Use it as a base for a new macro returning number of nanoseconds spent on evaluation of a given expression.

(defmacro nsecs
  `(let [start# (. System (nanoTime))]
     (- (. System (nanoTime)) start#)))

Need Your Help

PL/pgSQL functions: How to return table with an execute statement

function postgresql stored-procedures plpgsql

I've got this PL/pgSQL function which must return some users information.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.