Last active
August 11, 2020 16:37
-
-
Save jgpc42/81c392c59e8d56545b6e5519e733bec4 to your computer and use it in GitHub Desktop.
lein-jmh 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
{:benchmarks [(fn [] (Thread/sleep 0.1))]} |
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/main.clj | |
(ns demo.main | |
(:require [jmh.task :as task] | |
[jmh.core :as jmh] | |
[clojure.edn :as edn]) | |
(:gen-class)) | |
(defn -main [& [arg]] | |
(let [;; Create these however is appropriate for your use case: | |
env (edn/read-string (slurp "benchmarks.edn")) | |
opts (task/finalize-options (read-string arg)) | |
res (-> (jmh/run env opts) | |
(task/prepare-result opts))] | |
(task/report :pprint res) | |
(task/report :table res) | |
;; etc. | |
)) |
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"] | |
[jmh-clojure "0.3.1"] | |
[lein-jmh "0.2.8"]] | |
:profiles | |
{:uberjar | |
{:aot [demo.main] | |
:main demo.main | |
:uberjar-name "demo.jar"}}) |
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
lein uberjar | |
mkdir -p classes | |
java -cp classes:target/demo.jar demo.main '{:mode :single-shot, :status true}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment