Skip to content

Instantly share code, notes, and snippets.

View arthurprs's full-sized avatar
🌌

Arthur Silva arthurprs

🌌
  • Ditto
  • Stockholm
  • 07:16 (UTC +02:00)
View GitHub Profile
@arthurprs
arthurprs / main.rs
Created October 30, 2017 16:57
jemalloc bench
#![feature(global_allocator, test)]
extern crate jemallocator;
#[global_allocator]
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
extern crate jemalloc_sys;
fn main() { unsafe {
let ptr = jemalloc_sys::mallocx(100, 0);
let rsz1 = sallocx(ptr as usize, 0);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
➜ hashmap2 git:(layout) ✗ cargo-benchcmp hhkvkv:: orderm:: bench.txt
name hhkvkv:: ns/iter orderm:: ns/iter diff ns/iter diff %
grow_100_000 820,736 470,797 -349,939 -42.64%
grow_10_000 819,471 468,147 -351,324 -42.87%
grow_big_value_100_000 19,868,651 7,103,663 -12,764,988 -64.25%
grow_big_value_10_000 1,747,976 556,252 -1,191,724 -68.18%
grow_fnv_10_000 411,256 296,907 -114,349 -27.80%
insert_100 2,315 2,286 -29 -1.25%
insert_1000 22,907 23,622 715 3.12%
insert_100_000 4,266,405 2,726,115 -1,540,290 -36.10%
@arthurprs
arthurprs / Code.cpp
Last active October 17, 2016 21:20
SMHasher #37229
static const uint32_t kGoldenRatioU32 = 0x9E3779B9U;
static const uint64_t kGoldenRatioU64 = 0x517cc1b727220a95ULL;
inline uint32_t
RotateBitsLeft32(uint32_t aValue, uint8_t aBits)
{
return (aValue << aBits) | (aValue >> (32 - aBits));
}
use std::hash::{Hasher, BuildHasherDefault};
use std::collections::HashMap;
pub type IdHasherBuilder = BuildHasherDefault<IdHasher>;
pub type IdHashMap<K, V> = HashMap<K, V, IdHasherBuilder>;
pub struct IdHasher(u64);
impl Default for IdHasher {
#[inline]
fn default() -> IdHasher {
@arthurprs
arthurprs / here.rs
Created October 13, 2016 18:04 — forked from rrichardson/here.rs
#![feature(conservative_impl_trait)]
extern crate futures;
extern crate tokio_core;
use std::env;
use std::io;
use std::net::SocketAddr;
use futures::{Future, Poll, Async};
use futures::stream::Stream;
#![feature(sip_hash_13)]
use std::time;
use std::collections::HashMap;
use std::hash::{BuildHasher, BuildHasherDefault};
use std::hash::{SipHasher13, SipHasher24};
type TTTT = u32;
fn main() {
let a = time::SystemTime::now();
@arthurprs
arthurprs / main.rs
Last active August 29, 2015 14:13
Rust XXTEA
pub mod xtea {
const DELTA: u32 = 0x9e3779b9;
pub fn encrypt(value: &[u32], key: &[u32]) -> Vec<u32> {
// length of input as n for convinience
let n = value.len();
if n == 0 {
return Vec::new();