Skip to content

Instantly share code, notes, and snippets.

View jnordwick's full-sized avatar
🏝️
Wilson!!!

Jason Nordwick jnordwick

🏝️
Wilson!!!
View GitHub Profile
@jnordwick
jnordwick / gist:26acb66d05385d03795b
Created July 24, 2015 22:30
Rust nightly from 7/24/15 loop tests
jason@mintyfresh ~/rdev/rloop/src $ rustc --version
rustc 1.3.0-dev (5e6b53436 2015-07-24)
jason@mintyfresh ~/rdev/rloop/src $ cargo bench --verbose
Fresh rloop v0.1.0 (file:///home/jason/rdev/rloop)
Running `/home/jason/rdev/rloop/target/release/rloop-30eefaffa210e640 --bench`
running 16 tests
test extend1 ... bench: 1,043 ns/iter (+/- 79)
test extend2 ... bench: 1,049 ns/iter (+/- 60)
test extend_vecdeque1 ... bench: 1,069 ns/iter (+/- 10)
@jnordwick
jnordwick / gist:a01ce25acc8c13b4da34
Created July 24, 2015 22:31
stupid enum tricks
#[derive(Debug)]
enum List<T,L> {
Null(T),
Cell(T,L),
}
use List::*;
type Nil<T> = List<T,()>;
type Single<T> = List<T,Nil<T>>;
@jnordwick
jnordwick / avg.rs
Created July 30, 2015 22:13
count, sum, and avg macros in rust
macro_rules! avg {
($($t:expr),*) => (sum!($($t),*)/count!($($t),*));
}
macro_rules! count {
($h:expr) => (1);
($h:expr, $($t:expr),*) =>
(1 + count!($($t),*));
}
@jnordwick
jnordwick / cl.c
Last active August 16, 2024 18:10
// compile as:
// gcc -DCLSIZE=64 -O2 -c cl.c -o cl
// replace 64 with whatever value you want to pad to.
// this bash loop can be helpful:
// for x in 8 16 32 64 128 256; do gcc -DCLSIZE=${x} -O2 cl.c -o cl; ./cl; done
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <threads.h>
#include <stdatomic.h>