Skip to content

Instantly share code, notes, and snippets.

View smvv's full-sized avatar

Sander Mathijs van Veen smvv

View GitHub Profile
Length Normal arrays TypedArrays (before) TypedArrays (after)
Small (4) 340 ms 2400 ms 96 ms
Large (16) 510 ms 7900 ms 280 ms
Dynamic 5500 ms 12300 ms 1900 ms
@smvv
smvv / main.rs
Last active December 31, 2015 22:59
use std::run::{Process, ProcessOptions};
struct Gdb {
process: Process,
}
trait Debugger {
fn new(debuggee: ~str) -> Gdb;
fn send(&self, cmd: &str) -> int;
}
[
"assert",
"buffer_ieee754",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"_debugger",
@smvv
smvv / core.js
Last active December 21, 2015 04:38
module.exports = require('./core.json').reduce(function (acc, x) {
acc[x] = true;
return acc;
}
fn spawn(&self, request: mongrel2::Request) {
let (_, callback) = self.routes[0]; // TODO: url routing
let (port, chan) : (Port<~str>, Chan<~str>) = stream();
let env_request = request.clone();
do spawn {
callback(~Env {
out_ch: &chan,
//=== fields: ===
&[{
ident: {
name: 68,
ctxt: 0
},
expr: @{
id: 35,
node: expr_call(@{
id: 33,
@smvv
smvv / minimal.ll
Last active December 20, 2015 04:19
; ModuleID = 'minimal.rc'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%tydesc = type { i64, i64, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)*, void ({}*, i8*)* }
%"enum.TreeItem<int>" = type { i64 }
@_rust_crate_map_toplevel = global { i32, i8*, i64, [2 x i64] } { i32 1, i8* bitcast (void ({ i64, %tydesc*, i8*, i8*, i8 }*)* @"_ZN8unstable4lang10annihilate16_82984335c95fdd514_0$x2e8$x2dpreE" to i8*), i64 ptrtoint ([1 x { i64, i64 }]* @_rust_mod_map to i64), [2 x i64] [i64 ptrtoint (i64* @_rust_crate_map_std_0.8-pre_6c65cf4b443341b1 to i64), i64 0] }
@"_ZN8TreeItem8TreeLeaf7descrim17_86f9b6e6f0d35a7e7_0$x2e0E" = constant i64 0
@_rust_crate_map_std_0.8-pre_6c65cf4b443341b1 = external global i64
@smvv
smvv / minimal.rs
Last active December 20, 2015 04:18
pub struct BTree<V> {
node: TreeItem<V>,
}
pub enum TreeItem<V> {
TreeLeaf { value: V },
}
pub fn leaf<V>(value: V) -> TreeItem<V> {
TreeLeaf { value: value }
pub static BTREE_MIN_DEGREE : uint = 20;
//pub static BTREE_MIN_DEGREE : uint = 2;
pub static BTREE_KEYS_LBOUND : uint = BTREE_MIN_DEGREE - 1;
pub static BTREE_KEYS_UBOUND : uint = 2 * BTREE_MIN_DEGREE - 1;
pub struct BTree<K, V> {
priv used: uint,
priv keys: [Option<K>, ..BTREE_KEYS_UBOUND],
priv nodes: [Option<TreeItem<K, V>>, ..BTREE_KEYS_UBOUND + 1],
}
@smvv
smvv / zmq.rs
Last active December 20, 2015 00:19
/* Fix: add `#[deriving(Clone]' to the enum.
zmq.rc:200:8: 215:9 error: failed to find an implementation of trait std::clone::Clone for Error
zmq.rc:200 do getsockopt_int(self.sock, constants::ZMQ_TYPE).map |ty| {
zmq.rc:201 match *ty {
zmq.rc:202 0 => PAIR,
zmq.rc:203 1 => PUB,
zmq.rc:204 2 => SUB,
zmq.rc:205 3 => REQ,
*/