Skip to content

Instantly share code, notes, and snippets.


Yohaï-Eliel Berreby yberreby

View GitHub Profile
yberreby / results
Created Sep 4, 2016
Rust Benchmark - printing to stdout
View results
print_macro: 105 ns/iter (+/- 20)
print_macro_locked_stdoutbench: 87 ns/iter (+/- 22)
direct_locked_stdout: 17 ns/iter (+/- 2)
direct_unlocked_stdout: 51 ns/iter (+/- 9)
extern crate test;
use test::Bencher;
const LARGE_NUMBER: i32 = 1_000_000;
fn bench_even_imperative(b: &mut Bencher) {
b.iter(|| {
let mut list = Vec::with_capacity(LARGE_NUMBER as usize / 2 + 1);
View gist:09ff02b76affb254c8f9
### Keybase proof
I hereby claim:
* I am filsmick on github.
* I am yberreby ( on keybase.
* I have a public key whose fingerprint is 0D2A 6DC4 BFB5 8105 832B A469 803E 20B3 F3E1 9D9F
To claim this, I am signing this object:
yberreby /
Created Jun 28, 2015
src/libstd/rt/unwind/ - panic handler PoC
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
//> or the MIT license
// <LICENSE-MIT or>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
View gist:38d01523cfdbcdd9c97f
use std::thread;
use std::any::Any;
use std::rt::unwind::set_panic_handler;
fn main() {
// Use the default handler
panic!("Something's wrong"); // Prints "thread '<main>' panicked at 'Something's wrong', /Users/yohai/code/"
View gist:084c10fd23d0d6495b11
client_cargo/../src/ 121:46 error: no method named `should_close` found for type `core::cell::Ref<'_, glutin_window::GlutinWindow>` in the current scope
client_cargo/../src/ if window.borrow().should_close() { break; }
client_cargo/../src/ 121:46 help: items from traits can only be used if the trait is in scope; the following trait is implemented but not in scope, perhaps add a `use` for it:
client_cargo/../src/ 121:46 help: candidate #1: use `window::Window`
client_cargo/../src/ 161:50 error: mismatched types:
expected `event::event::Event<input::Input>`,
found `event::event::Event`
(expected enum `input::Input`,
found a different enum `input::Input`) [E0308]
yberreby / array_binsearch.cpp
Created Sep 11, 2014
Binary search implementation for native arrays
View array_binsearch.cpp
#include <iostream>
#include <vector>
using namespace std;
template <typename T>
int binary_search(const T& elem, const T* a, const size_t length) {
int middleIndex = length / 2;
T midpoint = a[middleIndex];
if (midpoint == elem) return middleIndex;