Skip to content

Instantly share code, notes, and snippets.

View toolslive's full-sized avatar

Romain Slootmaekers toolslive

  • Leuven, Belgium
View GitHub Profile
let bench n size combine =
let plist =
let rec loop acc i v =
if i = 0
then acc
else
let acc' = (v, string_of_int v ) :: acc in
loop acc' (i-1) (v+1)
in
loop [] size 0
@toolslive
toolslive / split_bench.ml
Last active November 11, 2016 11:38
split bench 2
let bench n size split =
let plist =
let rec loop acc i v =
if i = 0
then acc
else
let acc' = (v, string_of_int v ) :: acc in
loop acc' (i-1) (v+1)
in
loop [] size 0
@toolslive
toolslive / split_bench.ml
Last active October 27, 2016 17:19
micro bench compare List's split to a tail recursive version
let bench n size split =
let plist =
let rec loop acc i v =
if i = 0
then acc
else
let acc' = (v, string_of_int v ) :: acc in
loop acc' (i-1) (v+1)
in
loop [] size 0
@toolslive
toolslive / vararg.ml
Created July 9, 2013 13:22
varargs & arbitrary compile times
let sink (a,f) = f a
let base = ()
let finish () = ()
let step () = ()
let fold (a,f) g = g (a,f)
let step0 h (a,f) = fold (h a,f)
@toolslive
toolslive / gist:5908501
Last active December 19, 2015 05:59
oversleeping lwt threads?
open Lwt
let n = 1_000_000_000
let time f =
let t0 = Unix.gettimeofday () in
let a = f () in
let t1 = Unix.gettimeofday () in
a,(t1-.t0)
@toolslive
toolslive / gist:5721185
Created June 6, 2013 12:37
adding messages to an ftree
type ('k,'v) msg =
| Insert of 'k * 'v
| Delete of 'k
let key = function
| Insert (k,_) -> k
| Delete k -> k
type ('k,'v) row =
type ('a, 'e) result =
| OK of 'a
| NOK of 'e
let invoke (f: 'a -> 'b) x : unit -> 'b =
let input, output = Unix.pipe() in
match Unix.fork () with
| -1 -> (let v = f x in fun () -> v)
| 0 -> (* Child *)
@toolslive
toolslive / gist:4555867
Created January 17, 2013 13:14
my .emacs
(set-foreground-color "green")
(set-background-color "black")
;; intend using space instead of tabs
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq indent-line-function 'insert-tab)
(add-to-list 'load-path "~/.emacs.d")
(require 'weblogger)
module String = struct
include String
let show (t:string) = Printf.sprintf "%S" t
let pp formatter t =
Format.pp_print_string formatter t
end
module type E = sig
@toolslive
toolslive / install.sh
Last active August 29, 2015 14:26
helper script for orocksdb (3.12)
#!/usr/bin/env bash
set -x
echo $(gcc --version)
VERSION=3.12
shared_lib_file="/usr/local/lib/librocksdb.so.${VERSION}"
if [ -e $shared_lib_file ]; then
echo "$shared_lib_file exists"
else
echo "cloning, building, installing rocksdb"