Git Product home page Git Product logo

Comments (4)

jgpc42 avatar jgpc42 commented on May 28, 2024 1

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.

bsless avatar bsless commented on May 28, 2024 1

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.

jgpc42 avatar jgpc42 commented on May 28, 2024 1

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.

bsless avatar bsless commented on May 28, 2024

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)

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.