Skip to content

Instantly share code, notes, and snippets.

C:\Users\Alexis\Documents\GitHub\rust [mathjax +0 ~1 -0]> git status
# On branch mathjax
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: src/llvm (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
C:\Users\Alexis\Documents\GitHub\rust [mathjax +0 ~1 -0]> git diff
compile: x86_64-unknown-linux-gnu/rustllvm/RustWrapper.o
/home2bak/abeinges/rust2/src/rustllvm/RustWrapper.cpp: In function ‘LLVMOpaqueValue* LLVMDIBuilderCreateSubroutineType(DIBuilderRef, LLVMValueRef, LLVMValueRef)’:
/home2bak/abeinges/rust2/src/rustllvm/RustWrapper.cpp:285:18: error: ‘DITypeArray’ was not declared in this scope
unwrapDI<DITypeArray>(ParameterTypes)));
^
/home2bak/abeinges/rust2/src/rustllvm/RustWrapper.cpp:285:45: error: no matching function for call to ‘unwrapDI(LLVMOpaqueValue*&)’
unwrapDI<DITypeArray>(ParameterTypes)));
^
/home2bak/abeinges/rust2/src/rustllvm/RustWrapper.cpp:285:45: note: candidate is:
/home2bak/abeinges/rust2/src/rustllvm/RustWrapper.cpp:230:5: note: template<class DIT> DIT unwrapDI(LLVMValueRef)
@Gankra
Gankra / gist:93b2de2505ef438f1a0e
Last active August 29, 2015 14:07
libcollections documentation performance companion

This is written as a companion to the Rust collections library documentation. It provides an intuitive explanation of performance analysis in the context of data structures, with Rust's collections in mind.

Measuring Performance

The performance of a collection is a difficult thing to precisely capture. One cannot simply perform an operation and measure how long it takes or how much space is used, as the results will depend on details such as how it was compiled, the hardware it's running on, the software managing its execution, and

// set the matrix as a yaw rotation matrix
// if degree is true (!=0) then angle is given in degrees
// otherwise angle is given in radians
static Matrix4f rotateY(float angle, int degree);
// Editor's note: THIS LIBRARY IS SUPPOSED TO BE FOR OPENGL WHAT
Matrix4f * getViewMatrix(D3DXMATRIX * viewMatrix);
----- C:/g/rust/src/test/run-make/c-dynamic-dylib/ --------------------
------ stdout ---------------------------------------------
make[1]: Entering directory '/c/g/rust/src/test/run-make/c-dynamic-dylib'
gcc -Wall -Werror -g -m64 -D_WIN32_WINNT=0x0600 -L /C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib -c -o /C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib/libcfoo.o cfoo.c
gcc -Wall -Werror -g -m64 -D_WIN32_WINNT=0x0600 -L /C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib -o /C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib/cfoo.dll /C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib/libcfoo.o -shared
PATH="/C/g/rust/x86_64-pc-windows-gnu/test/run-make/c-dynamic-dylib:/C/g/rust/x86_64-pc-windows-gnu/stage2/bin:/mingw64/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/usr/bin:/c/ProgramData/Oracle/Java/javapath:/c/Program Files (x86)/Intel/iCLS Client:/c/Program Files/Intel/iCLS Client:/c/windows/system32:/c/windows:/c/windows/System32/Wbem:/c/windows/Sy
@Gankra
Gankra / gist:840b4a5eed0824d15d2b
Created November 22, 2014 20:46
libcollections benchmarks 2014-11-22
test bit::bitv_bench::bench_bitv_big_iter ... bench: 44040 ns/iter (+/- 28)
test bit::bitv_bench::bench_bitv_big_union ... bench: 2222 ns/iter (+/- 1)
test bit::bitv_bench::bench_bitv_set_big_fixed ... bench: 1386 ns/iter (+/- 1)
test bit::bitv_bench::bench_bitv_set_big_variable ... bench: 3093 ns/iter (+/- 2)
test bit::bitv_bench::bench_bitv_set_small ... bench: 1325 ns/iter (+/- 13)
test bit::bitv_bench::bench_bitv_small_iter ... bench: 881 ns/iter (+/- 4)
test bit::bitv_bench::bench_uint_small ... bench: 1175 ns/iter (+/- 26)
test bit::bitv_set_bench::bench_bitvset_big ... bench: 1410 ns/iter (+/- 13)
test bit::bitv_set_bench::bench_bitvset_iter ... bench: 46970 ns/iter (+/- 571)
test bit::bitv_set_bench::bench_bitvset_small ... bench: 1380 ns/iter (+/- 31)
/home/users/1/abeinges/rust/src/libcollections/bit.rs:925:30: 925:35 error: variable does not need to be mutable, #[deny(unused_mut)] on by default
/home/users/1/abeinges/rust/src/libcollections/bit.rs:925 pub fn from_fn<F>(len: uint, mut f: F) -> Bitv where F: FnMut(uint) -> bool {
^~~~~
error: aborting due to previous error
Fix that:
/home/users/1/abeinges/rust/src/libcollections/bit.rs:350:25: 350:26 error: cannot borrow immutable local variable `f` as mutable
/home/users/1/abeinges/rust/src/libcollections/bit.rs:350 bitv.set(i, f(i));
@Gankra
Gankra / gist:27cc5144e1272885ce5b
Last active August 29, 2015 14:11
binary search experiments
use std::slice::BinarySearchResult;
pub fn binary_search<F>(targ: &[u32], mut f: F) -> BinarySearchResult
where F: FnMut(&u32) -> Ordering {
let mut base : uint = 0;
let mut lim : uint = targ.len();
while lim != 0 {
let ix = base + (lim >> 1);
match f(&targ[ix]) {
This file has been truncated, but you can view the full file.
; ModuleID = 'lib.0.rs'
target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%str_slice = type { i8*, i64 }
%"struct.test::Bencher[#8]" = type { i64, %"struct.std::time::duration::Duration[#1]", i64 }
%"struct.std::time::duration::Duration[#1]" = type { i64, i32 }
%"struct.core::fmt::Arguments[#2]" = type { { %str_slice*, i64 }, %"enum.core::option::Option<[\22&\5C'static [core::fmt::rt::v1::Argument]\22]>[#2]", { %"struct.core::fmt::ArgumentV1[#2]"*, i64 } }
%"enum.core::option::Option<[\22&\5C'static [core::fmt::rt::v1::Argument]\22]>[#2]" = type { { %"struct.core::fmt::rt::v1::Argument[#2]"*, i64 } }
%"struct.core::fmt::rt::v1::Argument[#2]" = type { %"enum.core::fmt::rt::v1::Position[#2]", %"struct.core::fmt::rt::v1::FormatSpec[#2]" }
@Gankra
Gankra / gist:bff325dfd7b89e4f444f
Created February 11, 2015 21:07
from_elem benches
/*
test elem_000001 ... bench: 42 ns/iter (+/- 28)
test elem_000010 ... bench: 44 ns/iter (+/- 54)
test elem_000100 ... bench: 54 ns/iter (+/- 9)
test elem_001000 ... bench: 193 ns/iter (+/- 48)
test elem_010000 ... bench: 14487 ns/iter (+/- 17706)
test elem_100000 ... bench: 152159 ns/iter (+/- 46142)
test iter_000001 ... bench: 42 ns/iter (+/- 14)
test iter_000010 ... bench: 50 ns/iter (+/- 16)
test iter_000100 ... bench: 169 ns/iter (+/- 30)