GithubHelp home page GithubHelp logo

clj-load's Introduction

clj-load

A Clojure library using core.async for running concurrent processes repeatedly.

Usage

Example of running an action repeatedly and concurrently

;; Implement the Strategy protocol for executing a single test
;; and determining if the results from that execution are an error or not.
(defrecord GetStrategy [url]
  Strategy
  (exec [this lt]
    (print ".")
    @(http/get url))
  (error? [_ r] (or (:error r) (>= (:status r) 400))))


(defn run []
  (println "Running...")
  ;; Run 10 at a time for 100 total executions
  ;; The lt Map can contain other properties as well and each (exec) call will
  ;; have this Map passed to it as an argument.
  (let [lt {:count 100 :concurrent 10}
        ;; Create an instance of the Strategy
        strat (->GetStrategy "http://example.com")
        ;; Run everything and get the statistics back
        statistics (run-all lt strat)]

;; Statistics come back in a Map:
;;   {:success 10
;;     :failure 1
;;     :min 100
;;     :max 1000
;;     :mean 500
;;     :median 500
;;     :std-dev 15
;;     :elapsed 10000}

;; Handy function to print out the results
    (print-results statistics)))

License

Copyright © 2014 Geoff Lane [email protected]

Distributed under the The MIT License.

clj-load's People

Contributors

geofflane avatar

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.