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
public class Test { | |
private static int plusOne(int i) { | |
return ++i; | |
} | |
private static long oneForMethod(int x, int times) { | |
long start = System.nanoTime(); | |
for (int i = 0; i < times; i++) { |
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
defmodule PingPong do | |
def test(n, m) do | |
parent = self() | |
spawn fn -> | |
s = :erlang.monotonic_time(:microsecond) | |
{cs1,_} = :erlang.statistics(:context_switches) | |
{r1, _} = :erlang.statistics(:reductions) | |
first = self() | |
last = start(first, n, m) |
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
(ns test-delay | |
(:import [java.util.concurrent CyclicBarrier])) | |
(defn benchmark-delay [threads] | |
(let [n (rand-int 100) | |
d (delay (inc n)) | |
ret (inc n) | |
^CyclicBarrier barrier (CyclicBarrier. (+ threads 1))] | |
(dotimes [_ threads] | |
(-> |
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
cyear=$(date +"%Y") | |
cmonth=$(date +"%m") | |
cday=$(date +"%d") | |
isnum() { awk -v a="$1" 'BEGIN {print (a == a + 0)}'; } | |
for b in `git branch` | |
do | |
if [[ $b == feature/201* ]]; | |
then |
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
package net.fnil.java8_examples; | |
import java.util.concurrent.CountDownLatch; | |
import java.util.concurrent.CyclicBarrier; | |
import java.util.concurrent.atomic.AtomicInteger; | |
public class BusyLock { | |
private int count; | |
private AtomicInteger state; |
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
public class FalseSharing implements Runnable { | |
public final static int NUM_THREADS = 4; // change | |
public final static long ITERATIONS = 500L * 1000L * 1000L; | |
private final int arrayIndex; | |
private static VolatileLong3[] longs = new VolatileLong3[NUM_THREADS]; | |
static { | |
for (int i = 0; i < longs.length; i++) { | |
longs[i] = new VolatileLong3(); |
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
public class L1CacheMiss { | |
private static final int RUNS = 10; | |
private static final int DIMENSION_1 = 1024 * 1024; | |
private static final int DIMENSION_2 = 62; | |
private static long[][] longs; | |
public static void main(String[] args) throws Exception { | |
Thread.sleep(10000); | |
longs = new long[DIMENSION_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
(defn- get-ip-num [^String ip] | |
(when ip | |
(when-let [groups (re-matches #"^(\d+)\.(\d+)\.(\d+)\.(\d+)$" ip)] | |
(let [[a b c d] (map #(Integer/valueOf ^String %) (next groups))] | |
(+ | |
(* 256 256 256 a) | |
(* 256 256 b) | |
(* 256 c) | |
d))))) |
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
From d918ba819dc67d9977c3a13c1d3ac16e46e02dc4 Mon Sep 17 00:00:00 2001 | |
From: dennis zhuang <killme2008@gmail.com> | |
Date: Tue, 28 Jun 2016 00:30:16 +0800 | |
Subject: [PATCH] Patch Compiler#resolveIn to introduce method_missing | |
--- | |
src/jvm/clojure/lang/Compiler.java | 23 ++++++++++++++++++++--- | |
src/jvm/clojure/lang/Var.java | 9 +++++++++ | |
2 files changed, 29 insertions(+), 3 deletions(-) |
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
;;namespace test | |
(ns missing-test) | |
(defn method-missing [func args] | |
(println "missing '" func "' with args:" args) | |
[func args]) | |
(defn hello [name] | |
(str "hello," name)) |