Skip to content

Instantly share code, notes, and snippets.

View quasilyte's full-sized avatar
🕵️

quasilyte quasilyte

🕵️
View GitHub Profile
@quasilyte
quasilyte / channels.go
Created November 8, 2018 09:44
Channel vs mutex vs atomic for synchronized counter
package benchmark
import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
)
@quasilyte
quasilyte / main.go
Created January 11, 2023 10:06
Fixed timestep vs Delta time
package main
import (
"fmt"
"log"
"strings"
"time"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/ebitenutil"
class: \BenchmarkImplode
BenchmarkImplode::EmptyArray 595240 16.0 ns/op
BenchmarkImplode::EmptyArray 769240 16.0 ns/op
BenchmarkImplode::EmptyArray 1515160 16.0 ns/op
BenchmarkImplode::EmptyArray 1282060 16.0 ns/op
BenchmarkImplode::EmptyArray 1538480 17.0 ns/op
BenchmarkImplode::EmptyArray 1754400 16.0 ns/op
BenchmarkImplode::EmptyArray 1515160 16.0 ns/op
BenchmarkImplode::EmptyArray 1666680 16.0 ns/op
BenchmarkImplode::EmptyArray 1562500 16.0 ns/op
class: \BenchmarkImplode
BenchmarkImplode::EmptyArray 917440 18.0 ns/op
BenchmarkImplode::EmptyArray 1449280 18.0 ns/op
BenchmarkImplode::EmptyArray 952380 18.0 ns/op
BenchmarkImplode::EmptyArray 694460 18.0 ns/op
BenchmarkImplode::EmptyArray 1587320 18.0 ns/op
BenchmarkImplode::EmptyArray 1754400 19.0 ns/op
BenchmarkImplode::EmptyArray 1754400 19.0 ns/op
BenchmarkImplode::EmptyArray 1219520 17.0 ns/op
BenchmarkImplode::EmptyArray 1562500 19.0 ns/op
@quasilyte
quasilyte / nop.csv
Last active November 7, 2022 19:10
opcode encoding mode32 mode64 cpuid tags rw_actions multisize datasize
NOP 90+rd V V operand32,operand64 Y
NOP 90+rw V V operand16,operand64 Y
NOP F3 90+rd V V operand32 Y
NOP F3 90+rw V V operand16 Y
NOP r/m32 0F 18 /4 V V operand32 r Y 32
NOP r/m32 0F 18 /5 V V operand32 r Y 32
NOP r/m32 0F 18 /6 V V operand32 r Y 32
NOP r/m32 0F 18 /7 V V operand32 r Y 32
NOP r/m32, r32 0F 19 /r V V operand32 r,r Y 32
@quasilyte
quasilyte / no_preempt.go
Last active June 8, 2022 13:02
Example of a deadlock due to the lack of a better preemption in go scheduler
package main
import (
"fmt"
"runtime"
"time"
)
// Запускать через "go run no_preempt.go".
// См. также: https://github.com/golang/go/issues/10958.
package main
import "sync"
// Запустите с помощью "go run -race datarace.go".
var globalX int
func main() {
var wg sync.WaitGroup
@quasilyte
quasilyte / old.txt
Last active December 8, 2021 09:03
bytes.Buffer grow raw benchmarks data for "old"
goos: linux
goarch: amd64
pkg: bench
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkBufferWrite/len1_x1-8 12748204 95.32 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12389413 95.25 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12452178 92.79 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12876642 96.28 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 13010896 94.67 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12296984 95.91 ns/op 64 B/op 1 allocs/op
@quasilyte
quasilyte / new.txt
Created December 8, 2021 09:03
bytes.Buffer grow raw benchmarks data for "new"
goos: linux
goarch: amd64
pkg: bench
cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
BenchmarkBufferWrite/len1_x1-8 13595941 95.07 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 13895242 94.19 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12867998 95.91 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12298687 94.02 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 13148979 95.40 ns/op 64 B/op 1 allocs/op
BenchmarkBufferWrite/len1_x1-8 12081237 95.04 ns/op 64 B/op 1 allocs/op
@quasilyte
quasilyte / perf_test.go
Created December 8, 2021 08:59
bytes.Buffer grow benchmarks
package main
import (
"bytes"
"encoding/xml"
"fmt"
"html/template"
"strings"
"testing"
)