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
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"
@toolslive
toolslive / gist:56b9fae64b27d3e00971
Last active August 29, 2015 14:25
helper script for orocksdb
#!/usr/bin/env bash
set -x
echo $(g++ --version)
shared_lib_file="/usr/local/lib/librocksdb.so"
if [ -e $shared_lib_file ]; then
echo "$shared_lib_file exists"
else
echo "cloning, building, installing rocksdb"
git clone https://github.com/facebook/rocksdb/
cd rocksdb
@toolslive
toolslive / tail.ml
Created April 3, 2014 06:26
memory leak with Lwt.catch
open Lwt
let do_something i =
let x = Random.int 100 in
Lwt_io.printlf "%i: x = %i" i x >>= fun () ->
if (x < 2)
then Lwt.fail (Failure "kaboom")
else Lwt.return ()
let rec loop1 i =
@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 =