Skip to content

Instantly share code, notes, and snippets.

View zhyon404's full-sized avatar
👓
Ex...

zhyon404

👓
Ex...
View GitHub Profile
select {
case <-ch:
// channel is closed, this is executed
default:
// channel is still open, the previous case is not executed
close(ch)
}
once := sync.Once{}
func Test_double_check_unsafe(t *testing.T) {
m := make(map[int]int64)
mu := sync.Mutex{}
wg := sync.WaitGroup{}
wg.Add(100 * 10)
for i := 0; i < 100; i++ {
for j := 0; j < 10; j++ {
go func(j int) {
defer wg.Done()
v := m[j]
m := make(map[[8]byte][]int64, 1e8)
for i := 0; i < 10; i++ {
start := time.Now()
runtime.GC()
fmt.Printf("GC took %s\n", time.Since(start))
}
runtime.KeepAlive(m)
//x := 10
//var mx [x]int
//fmt.Println(mx)
func floatSlice2bytes(s []float64) []byte {
b := (*reflect.SliceHeader)(unsafe.Pointer(&s))
b.Cap = b.Cap * 8
b.Len = b.Len * 8
return *(*[]byte)(unsafe.Pointer(&s))
}
func bytes2floatSlice(s []byte) []float64 {
b := (*reflect.SliceHeader)(unsafe.Pointer(&s))
b.Cap = b.Cap / 8
! Put user rules line by line in this file.
! See https://adblockplus.org/en/filter-cheatsheet
||redis.io
||segment.com
||todoist.com
||cheney.net
||cncf.io
||influxdata.com
||quora.com
||todoist.com