Last active
August 14, 2020 18:26
-
-
Save jgpc42/a694c8b4255ed332dac38428bd4e0546 to your computer and use it in GitHub Desktop.
jmh-clojure uberjar example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; src/demo/core.clj | |
(ns demo.core | |
(:require [clojure.core.async :as async])) | |
(defn blocking-put [ch] | |
(async/>!! ch 42)) | |
(defn blocking-take [ch] | |
(async/<!! ch)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; resources/jmh.edn | |
{:benchmarks | |
[{:name :put | |
:fn demo.core/blocking-put | |
:args [:chan] | |
:options {:threads 3}} | |
{:name :take | |
:fn demo.core/blocking-take | |
:args [:chan]}] | |
:states | |
{:chan | |
{:scope :group :fn clojure.core.async/chan :args [:chan-n]}} | |
:params | |
{:chan-n [1]} | |
:options | |
{:async | |
{:group :g | |
:timeout [1 :sec] | |
:mode :average | |
:output-time-unit :ns | |
:fork {:count 1 :warmups 0} | |
:measurement 2 | |
:warmup 2}}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject demo "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.10.1"] | |
[org.clojure/core.async "1.3.610"]] | |
:plugins [[lein-jmh "0.3.0-SNAPSHOT"]] | |
:profiles {:jmh {:jvm-opts []} | |
:uberjar {:dependencies [[jmh-clojure/task "0.1.0-SNAPSHOT"]] | |
:main jmh.main | |
:aot [jmh.main]}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
set -e | |
lein uberjar | |
mkdir -p target/tmp/classes && cd target/tmp | |
cp=classes:../demo-0.1.0-SNAPSHOT-standalone.jar | |
java -Dfile.encoding=UTF-8 -cp "$cp" jmh.main '{:fail-on-error false, :format [:table :pprint], :type :async, :status true, :verbose true}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment