Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pspy* function #47

Closed
weavejester opened this issue Jan 6, 2014 · 4 comments
Closed

Add a pspy* function #47

weavejester opened this issue Jan 6, 2014 · 4 comments

Comments

@weavejester
Copy link

Currently pspy is a macro, which makes it hard to incorporate into a generalised function. For example, I can't write:

(pspy (var-name v) (test-var v))

To profile my tests.

To fix this, please consider a refactor along the following lines:

(defn pspy* [name func]
  (if-not *pdata*
    (func)
    (let [name (utils/fq-keyword name)
          start-time (System/nanoTime)]
      (try (func)
           (finally
             (let [elapsed (- (System/nanoTime) start-time)]
               (swap! *pdata* #(assoc % name (conj (% name []) elapsed)))))))))

(defmacro pspy [name & body]
  `(pspy* ~name (fn [] ~@body))
@ptaoussanis
Copy link
Member

Hey James, sure - that'd be a welcome change. You want to submit a PR, or prefer that I do it?

@ptaoussanis
Copy link
Member

Hey James, this'll be included in an upcoming version.

@weavejester
Copy link
Author

Thanks - sorry for the delay. I got dragged onto other things and completely forgot about this.

@ptaoussanis
Copy link
Member

No problem - cheers! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants