Giter Site home page Giter Site logo

goat's Introduction

goat

A clojure library designed to profile clojure function performance during runtime.

The instrumentation is meant to be run from a repl and can be removed and added dynamically.

The api makes use of https://github.com/technomancy/robert-hooke for adding hooks arround instrumented functions, and was inspired by https://github.com/MichaelDrogalis/night-vision.

Usage

Add this to your project.clj :dependencies list:

[goat "0.1.0-SNAPSHOT"]

Examples

(use 'goat.core)

;;dummy function
(defn myfun [n] (Thread/sleep n))

;;instrument a namespace
(instrument-functions! 'user)

(myfun 100)

;;collect performance data for a method

(get-fperf 'user/myfun) 

;;#goat.core.FPerf{:name user/myfun, :call-count 1, :total-time 101}

;;reset instrumentation for 'user)
(reset-instrumentation! 'user)

;;reset all instrumentation
(reset-instrumentation!)

;;view perf data
(get-fperf-data)
;;{user/cdoc #goat.core.FPerf{:name user/cdoc, :call-count 0, :total-time 0}, 
;;user/help #goat.core.FPerf{:name user/help, :call-count 0, :total-time 0}, 
;;user/apropos-better #goat.core.FPerf{:name user/apropos-better, :call-count 0, :total-time 0},
;;user/set-signal-handler! #goat.core.FPerf{:name user/set-signal-handler!, :call-count 0, :total-time 0}, 
;;user/myfun #goat.core.FPerf{:name user/myfun, :call-count 2, :total-time 203}, 
;;user/find-name #goat.core.FPerf{:name user/find-name, :call-count 0, :total-time 0}, 
;;user/clojuredocs #goat.core.FPerf{:name user/clojuredocs, :call-count 0, :total-time 0}}

Ordering stats

(use 'goat.core)

(defn myfun [n] (Thread/sleep n))
(defn abc [] (+ 1 2))

(instrument-functions! 'user)
(myfun 100)
(doseq [i (range 10)] (abc))

;;get-top-fperf filters out call-count == 0 and returns ordered by total-count and total-time
(get-top-fperf 3)
;;(#goat.core.FPerf{:name user/myfun, :call-count 1, :total-time 100} 
;; #goat.core.FPerf{:name user/abc, :call-count 10, :total-time 0})

;;filter only by call-count
(get-top-fperf 3 :call-count)
;;(#goat.core.FPerf{:name user/abc, :call-count 10, :total-time 0} 
;; #goat.core.FPerf{:name user/myfun, :call-count 1, :total-time 100})

License

Copyright 2013 Gerrit Jansen van Vuuren and contributors

Distributed under the Eclipse Public License, the same as Clojure.

goat's People

Contributors

gerritjvv avatar inaimathi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

inaimathi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.