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
*clojure-version* ;; => {:major 1, :minor 10, :incremental 3, :qualifier nil} | |
(System/getProperty "java.version") ;; => "14.0.1" | |
(import [clojure.asm ClassVisitor ClassWriter Opcodes Type] | |
[clojure.lang DynamicClassLoader RT]) | |
(defn type-to-desc [t] | |
(case t | |
:int "I" | |
;; ... and so on |
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
(prn *compiler-options*) | |
; => {:direct-linking true, :disable-locals-clearing true} | |
(require '[no.disassemble :as dis]) | |
(defn reset-atom [a] | |
(swap! a (fnil inc 0))) | |
(defn xxx [a] | |
(reset-atom a)) |
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
{: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/Native.java | |
package demo; | |
import java.util.concurrent.ThreadLocalRandom; | |
import org.openjdk.jmh.annotations.*; | |
public class Native { | |
@Benchmark | |
public Object addBoxed (LongState a, LongState b) { |
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
;; scripts/bench.clj | |
(ns bench | |
(:require [criterium.core :as crit] | |
[jmh.core :as jmh] | |
[clojure.java.io :as io] | |
[clojure.edn :as edn] | |
[demo.core :as demo] | |
[demo.utils :as utils] | |
[clojure.pprint :refer [pprint]])) |
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
(import [java.io InputStream]) |
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
(import [java.io InputStream]) |
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
;; $ java -cp ~/.lein/self-installs/leiningen-2.7.1-standalone.jar clojure.main hashcode-bench.clj | |
(println "Java" (System/getProperty "java.version")) | |
(println "Clojure" (apply str ((juxt :major (constantly \.) :minor) *clojure-version*))) | |
;; => Java 1.8.0_131 | |
;; => Clojure 1.8 | |
(require '[cemerick.pomegranate :as pom]) |