Skip to content

Instantly share code, notes, and snippets.

View zhangyunhao116's full-sized avatar
💭
I may be slow to respond.

ZhangYunHao zhangyunhao116

💭
I may be slow to respond.
  • 04:21 (UTC +08:00)
View GitHub Profile
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)
@zhangyunhao116
zhangyunhao116 / bench.rs
Last active February 3, 2023 17:26
Optimze break patterns
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
};
@zhangyunhao116
zhangyunhao116 / asm_amd64.s
Last active October 18, 2022 15:15
fxhash vs wyhash (uint64)
#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
@zhangyunhao116
zhangyunhao116 / bench.rs
Created February 9, 2022 04:47
heapsort benchmarks (rust)
#![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,
{
package clist
import (
"fmt"
"sync"
"sync/atomic"
"testing"
_ "unsafe" // for linkname
)
package simplelist
import (
"sync"
)
type IntList struct {
head *intNode
length int64
mu sync.RWMutex