Skip to content

Instantly share code, notes, and snippets.

View danielmatz's full-sized avatar

Daniel Matz danielmatz

View GitHub Profile
@danielmatz
danielmatz / zeros_test.jl
Created October 18, 2016 01:57
Comparison of implementations of zeros
using BenchmarkTools
function zeros_calloc{S, N}(T::Type, dims::Vararg{S, N})
data = ccall((:calloc, "libc"),
Ptr{Void},
(Csize_t, Csize_t),
prod(dims), sizeof(T))
data == C_NULL && error("Failed to allocate memory")
ccall(:jl_ptr_to_array,
Array{T, N},
@danielmatz
danielmatz / fast.jl
Last active August 29, 2015 14:17
Understanding the Cost of Virtualization
type ChildA
end
type ChildB
end
increment(c::ChildA, x) = x + 1
increment(c::ChildB, x) = x + 2
type Container
@danielmatz
danielmatz / fishtrace
Created February 22, 2015 05:18
Fish freezes and then crashes when the current directory is within a large hg-git repo
Time Sum Command
1116 4995 > builtin source /usr/local/stow/fish-shell/share/fish/config.fish 2>/dev/null
68 68 -> set -g IFS \n\ \t
15 15 -> function __fish_default_command_not_found_handler...
17 17 -> function __fish_command_not_found_handler --on-event fish_command_not_found...
54 54 -> set -l configdir ~/.config
10 25 -> if set -q XDG_CONFIG_HOME...
15 15 --> set -q XDG_CONFIG_HOME
38 38 -> set -l userdatadir ~/.local/share
6 20 -> if set -q XDG_DATA_HOME...
# 1 "mimedb.cpp"
# 1 "/Users/dmatz/Data/Projects/fish-shell//"
# 1 "<command-line>"
# 1 "mimedb.cpp"
# 22 "mimedb.cpp"
# 1 "config.h" 1
# 23 "mimedb.cpp" 2
# 1 "/usr/include/string.h" 1 3 4