Skip to content

Instantly share code, notes, and snippets.

@llogiq
llogiq / gist:27bed898dcf36fc47544
Created July 28, 2014 13:03
Caliper Benchmark pitting trove's TIntHashSet against hftc's HashIntSet (mixed add and contains)
import gnu.trove.set.TIntSet;
import gnu.trove.set.hash.TIntHashSet;
import java.util.concurrent.ThreadLocalRandom;
import net.openhft.collect.set.hash.HashIntSet;
import com.google.caliper.Benchmark;
import com.google.caliper.runner.CaliperMain;
@llogiq
llogiq / vec_map_bench.rs
Last active August 29, 2015 14:22
DefaultVecMap class with benchmark
#![feature(test, rand)]
/// benchmarks for different map implementation
extern crate test;
extern crate rand;
use test::Bencher;
use rand::Rng;
use std::mem::replace;
@llogiq
llogiq / loops.rs
Created June 16, 2015 09:30
A better loop benchmark
#![feature(test)]
#![feature(step_by)]
extern crate test;
fn for_loop() -> usize {
let mut counter = 1;
for i in (0..1_000_000) {
counter += test::black_box(i);
}
@llogiq
llogiq / rot_bench.rs
Last active August 29, 2015 14:25
Microbenchmark of the fannkuch_redux' rotate method
#![feature(test)]
extern crate test;
use std::mem;
use std::intrinsics::copy;
fn rotate(x: &mut [i32]) {
let mut prev = x[0];
for place in x.iter_mut().rev() {
@llogiq
llogiq / clippy-rust.txt
Created September 3, 2015 07:58
Output of clippy on Rust stage 2
~/projects/rust$ ./configure --enable-compiler-docs
configure: looking for configure programs
configure: found program 'cmp'
configure: found program 'mkdir'
configure: found program 'printf'
configure: found program 'cut'
configure: found program 'head'
configure: found program 'grep'
configure: found program 'xargs'
configure: found program 'cp'
//! rustc -C opt-level=3 --test cowbell.rs && ./cowbell --bench
//!
//! running 8 tests
//! test empty ... bench: 0 ns/iter (+/- 0)
//! test format_str ... bench: 70 ns/iter (+/- 2)
//! test format_str_cow ... bench: 76 ns/iter (+/- 0)
//! test format_string ... bench: 75 ns/iter (+/- 0)
//! test format_string_cow ... bench: 78 ns/iter (+/- 1)
//! test to_cow ... bench: 2 ns/iter (+/- 0)
//! test to_owned_cow ... bench: 27 ns/iter (+/- 0)
@llogiq
llogiq / stage2.log
Created September 9, 2015 04:15
A log of compiling rust as of 474ad2f / stage 2 with rust-clippy
cfg: version 1.4.0-dev (474ad2fc7 2015-09-08)
cfg: build triple i686-unknown-linux-gnu
cfg: host triples i686-unknown-linux-gnu
cfg: target triples i686-unknown-linux-gnu
cfg: host for i686-unknown-linux-gnu is i386
cfg: os for i686-unknown-linux-gnu is unknown-linux-gnu
cfg: good valgrind for i686-unknown-linux-gnu is 1
cfg: using CC=gcc (CFG_CC)
cfg: enabling valgrind run-pass tests (CFG_ENABLE_VALGRIND_RPASS)
cfg: valgrind-rpass command set to "/usr/bin/valgrind" --error-exitcode=100 --fair-sched=try --quiet --soname-synonyms=somalloc=NONE --suppressions=/home/andre/projects/rust/src/etc/x86.supp --tool=memcheck --leak-check=full
// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// contributed by llogiq
//
// built on top of Joshua Landau's fasta
// built on top of Rust versions
// contributed by the Rust Project Developers
// contributed by TeXitoi
// multi-threaded version contributed by Alisdair Owens
class F{public static void main(String[]r){int a=1,i=1;for(;i<=new Integer(r[0]);i++){a*=i;}System.out.print(a);}}
class G{public static void main(String[]r){for(long a=0,b=1,i=0,c;i++<50;){c=a;a+=b;b=c;System.out.println(a);}}}