Skip to content

Instantly share code, notes, and snippets.

View binarybana's full-sized avatar

Jason Knight binarybana

View GitHub Profile
@binarybana
binarybana / ghc-install-ubuntu-src.sh
Created February 4, 2012 05:05
How to install GHC 7.4.1 in Ubuntu from source
#Install prerequisites
sudo aptitude install ghc darcs zlib1g-dev libncurses5-dev
#Get GHC 7.4.1 source and cabal-install HEAD
wget http://www.haskell.org/ghc/dist/7.4.1/ghc-7.4.1-src.tar.bz2
darcs get --lazy http://darcs.haskell.org/cabal/
tar xjf ghc-7.4.1-src.tar.bz2
cd ghc-7.4.1
./configure --prefix=$HOME/src/ghc
time make -j9 #Only took me about 19 minutes on recent quad core xeon
@binarybana
binarybana / test.jl
Created October 22, 2012 00:54
Julia/Python Dictionary Microbenchmark
function stress0(N::Int)
x = Dict{Int,Float64}()
for i = 1:N
x[i] = 0.0
end
return x
end
function stress0prime(N::Int)
x = Dict{Int,Float64}(N)
@binarybana
binarybana / pyrunner.py
Created November 5, 2012 17:43
Julia Python microbenchmarks take 2
from timeit import timeit
A = timeit(setup = 'import test,random; n = range(10**6)', stmt = 'test.stress1(n)',
number=5) / 5.0
B = timeit(setup = 'import test,random; n = range(10**6); random.shuffle(n)',
stmt = 'test.stress1(n)',
number=5) / 5.0
C = timeit(setup='import test,random; n = [random.randint(0,100) for i in range(10**6)]',
stmt = 'test.stress1(n)',
number=5) / 5.0
@binarybana
binarybana / driver_1.jl
Created December 16, 2012 20:03
A minimal test case for an inter-module profiling bug.
require("fancy")
using Fancy
do_fancy(100)
Fancy.@profile report
require("profile")
using Profile
@profile begin
##############################################################################
#
# Low-level text parsing
#
##############################################################################
# Implements a very simple two-state machine that splits *-separated
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg%3Ef.fn.jquery%7C%7Ch(f))%7Bc=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd==%22loaded%22%7C%7Cd==%22complete%22))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,%221.3.2%22,function($,L)%7B$('%23header,%20.pagehead,%20.breadcrumb,%20.commit,%20.meta,%20%23footer,%20%23footer-push,%20.wiki-actions,%20%23last-edit,%20.actions,%20.header').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D);
@binarybana
binarybana / times.md
Last active December 11, 2015 07:48
A set of timings for parallel compression utilities in Linux

Baseline

cat test.fastq 2>&3 0.00s user 0.17s system 98% cpu 0.171 total
cat test.fastq 2>&3 0.00s user 0.16s system 97% cpu 0.164 total

Compressing

gzip -c test.fastq 2>&3 84.22s user 0.19s system 99% cpu 1:24.59 total
gzip -c test.fastq 2>&3 96.61s user 0.96s system 94% cpu 1:43.75 total
pigz -c test.fastq 2>&3 88.85s user 0.34s system 1181% cpu 7.546 total
lbzip2 -c test.fastq 2>&3 91.08s user 3.01s system 1142% cpu 8.238 total
bzip2 -c test.fastq 2>&3 93.33s user 0.22s system 99% cpu 1:33.77 total

@binarybana
binarybana / fastq.jl
Created June 12, 2013 01:53
Buffered IO in Julia
function read_buf(fname::ASCIIString, copybuf::Bool)
fsize = filesize(fname)
fid = open(fname)
line = 0
reads = 0
bufsize = 4096
buf = zeros(Uint8, bufsize)
mydata = zeros(Uint8, bufsize)
while position(fid) < (fsize-bufsize)
read(fid, buf)
@binarybana
binarybana / centos 5
Created July 18, 2013 03:31
Julia build errors on CentOS
src/s_cpow.c.o: In function `__signbitf':
s_cpow.c:(.text+0x0): multiple definition of `__signbitf'
src/s_signbit.c.o:s_signbit.c:(.text+0x10): first defined here
src/s_cpow.c.o: In function `__signbit':
s_cpow.c:(.text+0x10): multiple definition of `__signbit'
src/s_signbit.c.o:s_signbit.c:(.text+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `__signbit' changed from 16 in src/s_signbit.c.o to 19 in src/s_cpow.c.o
src/s_cpow.c.o: In function `__signbitl':
s_cpow.c:(.text+0x30): multiple definition of `__signbitl'
src/s_signbit.c.o:s_signbit.c:(.text+0x20): first defined here
execve("./julia", ["./julia"], [/* 33 vars */]) = 0
brk(0) = 0x173f6000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2aaaaaaab000
uname({sys="Linux", node="compute-0-1.local", ...}) = 0
readlink("/proc/self/exe", "/home/jason/src/julia/usr/bin/ju"..., 4096) = 52
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/home/jason/src/julia/usr/bin/../lib/julia/tls/x86_64/libncurses.so.5", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/jason/src/julia/usr/bin/../lib/julia/tls/x86_64", 0x7fff0455e040) = -1 ENOENT (No such file or directory)
open("/home/jason/src/julia/usr/bin/../lib/julia/tls/libncurses.so.5", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/jason/src/julia/usr/bin/../lib/julia/tls", 0x7fff0455e040) = -1 ENOENT (No such file or directory)