This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package simplelist | |
import ( | |
"sync" | |
) | |
type IntList struct { | |
head *intNode | |
length int64 | |
mu sync.RWMutex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package clist | |
import ( | |
"fmt" | |
"sync" | |
"sync/atomic" | |
"testing" | |
_ "unsafe" // for linkname | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(test)] | |
use criterion::{criterion_group, criterion_main, Criterion}; | |
use rand::distributions::Standard; | |
use rand::{thread_rng, Rng}; | |
pub fn heapsort<T, F>(v: &mut [T], mut is_less: F) | |
where | |
F: FnMut(&T, &T) -> bool, | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "textflag.h" | |
TEXT ·memhash64(SB),NOSPLIT,$0-24 | |
// AX = data | |
// BX = seed | |
MOVQ data+0(FP), AX | |
MOVQ seed+8(FP), BX | |
MOVQ BX, X0 // X0 = seed | |
PINSRQ $1, AX, X0 // data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use criterion::{criterion_group, criterion_main, Criterion}; | |
fn r1(len: usize) -> usize { | |
let mut random = len as u32; | |
let mut gen_u32 = || { | |
random ^= random << 13; | |
random ^= random >> 17; | |
random ^= random << 5; | |
random | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name old time/op new time/op delta | |
MapIter/Int/6-16 47.2ns ± 0% 43.7ns ± 0% -7.45% (p=0.000 n=8+10) | |
MapIter/Int/12-16 82.0ns ± 1% 78.0ns ± 0% -4.84% (p=0.000 n=8+8) | |
MapIter/Int/18-16 131ns ± 3% 122ns ± 7% -6.82% (p=0.000 n=10+10) | |
MapIter/Int/24-16 157ns ± 4% 146ns ± 5% -7.49% (p=0.000 n=10+10) | |
MapIter/Int/30-16 211ns ± 1% 204ns ± 2% -3.03% (p=0.000 n=10+9) | |
MapIter/Int/64-16 409ns ± 2% 393ns ± 2% -3.86% (p=0.000 n=10+10) | |
MapIter/Int/128-16 803ns ± 6% 777ns ± 2% -3.24% (p=0.001 n=10+9) | |
MapIter/Int/256-16 1.68µs ± 2% 1.48µs ± 5% -12.02% (p=0.000 n=10+10) | |
MapIter/Int/512-16 3.72µs ± 2% 2.98µs ± 3% -19.94% (p=0.000 n=10+9) |