Comments (2)
Hi, thanks for opening this issue.
I've never used boot
, so this took some time to figure out. It looks like it has to do with how it dynamically manages the class path.
For example, if I lein repl
or clj
into the example project and evaluate (System/getProperty "java.class.path")
, I get the expected entries including jmh-core-1.19.jar
, etc.
If I use boot repl
however, the property is missing the expected entries and is just a single path. A cursory search yielded this issue, which looks like it might be related.
You can "fix" boot by altering the example REPL session from the README like so:
(require '[jmh.core :as jmh]
'[clojure.java.io :as io]
'[clojure.edn :as edn])
(def bench-env
(-> "benchmarks.edn" io/resource slurp edn/read-string))
;; The class path used for dynamic java compilation and JMH forks
(def boot-classpath
(str (System/getProperty "fake.class.path")
java.io.File/pathSeparator
*compile-path*))
(System/setProperty "java.class.path" boot-classpath)
(jmh/run bench-env {:type :quick})
It seems the fake.class.path
property is the canonical workaround (?) when using boot with libraries like jmh-clojure
and others that expect standard class path semantics.
Again, I have no real experience with boot, so I'd appreciate any feedback from boot users on how to better support it with a more idiomatic solution.
from jmh-clojure.
Yes, it seems the correct way to handle issues like this. FWIW, I’ve also tried to define a task. Something like:
(deftask jmh
"Run JMH benchmarks"
[c benchmark-configuration VALUE str "resource EDN file with benchmark configuration"]
(let [bench-env (-> benchmark-configuration
clojure.java.io/resource
slurp
clojure.edn/read-string)
;; to be extracted?
bench-opts
{:type :quick
:params {:count [31 100000]}
:profilers ["gc"]}]
(fn [continue]
(fn [event]
(System/setProperty "java.class.path"
(str (System/getProperty "fake.class.path")
java.io.File/pathSeparator
*compile-path*))
(jmh/run bench-env bench-opts)
(continue event)))))
But it fails. Whereas I can call a simple function like this:
(defn run-benchmarks! [benchmark-configuration bench-opts]
(System/setProperty "java.class.path"
(str (System/getProperty "fake.class.path")
java.io.File/pathSeparator
*compile-path*))
(jmh/run (-> benchmark-configuration
clojure.java.io/resource
slurp
clojure.edn/read-string)
bench-opts))
Anyway, I think I can close this? Thank you for the quick reply!
from jmh-clojure.
Related Issues (9)
- NullPointerException when any benchmark is not matched by :selector predicate HOT 4
- Valid clj keyword benchmark names are munged to invalid Java method names HOT 6
- Implicit default selectors to simplify :select usage HOT 2
- Examples in README fail due to clojure.lang.Named cast exception HOT 2
- Support params in :options map HOT 3
- Support Clojure 1.9 clj tool HOT 3
- byte-code level incompatibility with Java <= 13 HOT 11
- Best way to benchmark a variable number of arguments HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmh-clojure.