Comments (4)
It's an interesting problem. Another instance of macros causing issues. Anyway, from what I can tell, something like that, or a variation of that, looks like the right solution. What also may work is bypassing the macro and just benchmarking the resulting lens/get
invocation directly, but I don't know if that is possible in your case.
Thanks for bringing this to my attention.
Edit: Nevermind, I see that lens/get
is just a code transformer.
from jmh-clojure.
Thank you for taking the time to look at it anyway.
The problem with macros is that once you start with them, they're hard to get rid of :)
You can take a peek at the branch I started working on to see the approach I ended up taking
see here:
https://github.com/bsless/clj-fast/blob/jmh/extra/clj-fast.jmh/src/clj_fast/bench.clj#L168
https://github.com/bsless/clj-fast/blob/jmh/extra/clj-fast.jmh/jmh.edn
In the end, just dancing around delayed application, as always
I also feel I must commend how you went above and beyond and looked through the implementation. Thank you!
from jmh-clojure.
No problem - I always enjoy checking out how others are using this library, and I like your approach here quite a bit. One of the pain points I've experienced developing this library has always been the mismatch of the static nature of Java (for which JMH was designed) vs. the dynamic nature of Clojure and you've worked around this quite nicely from what I see here.
Nice talking to you, and thank you for your kind words!
from jmh-clojure.
Managed to work something out by using partial application:
(defn inline-get-in-fn
[[k1 k2 k3 k4 :as ks]]
(case (count ks)
1 (fn [m] (inline/get-in m [k1]))
2 (fn [m] (inline/get-in m [k1 k2]))
3 (fn [m] (inline/get-in m [k1 k2 k3]))
4 (fn [m] (inline/get-in m [k1 k2 k3 k4]))))
(defn invoke
([f] (f))
([f a] (f a))
([f a b] (f a b)))
Then it works with the following config:
{:benchmarks
[{:name :core/get-in :fn clojure.core/get-in :args [:state/map :state/ks]}
{:name :inline/get-in :fn clj-fast.bench/invoke :args [:state/inline-get-in-fn :state/map]}]
:states
{:map-size {:fn (fn [x] (int (Math/pow 10 x))) :args [:param/log-map-size]}
:map {:fn clj-fast.bench/mrand-nested-map :args [:param/type :state/map-size :param/keys-depth]}
:inline-get-in-fn {:fn clj-fast.bench/inline-get-in-fn :args [:state/ks]}
:ks {:fn clj-fast.bench/randpath :args [:state/map]}}
:params
{:log-map-size [0 #_#_1 2]
:keys-depth [1 2 #_3 #_4]
:type :keyword?}}
from jmh-clojure.
Related Issues (9)
- NullPointerException when any benchmark is not matched by :selector predicate HOT 4
- 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
- "package org.openjdk.jmh.annotations does not exist" when using boot HOT 2
- byte-code level incompatibility with Java <= 13 HOT 11
- Valid clj keyword benchmark names are munged to invalid Java method names HOT 6
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.