Skip to content

Instantly share code, notes, and snippets.

View quasilyte's full-sized avatar
🕵️

quasilyte quasilyte

🕵️
View GitHub Profile
@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 / 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 / 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 / perf_test.go
Created December 8, 2021 08:59
bytes.Buffer grow benchmarks
package main
import (
"bytes"
"encoding/xml"
"fmt"
"html/template"
"strings"
"testing"
)
@quasilyte
quasilyte / results.txt
Created December 8, 2021 08:58
bytes.Buffer grow benchmarks comparison
name old time/op new time/op delta
BufferWrite/len1_x1-8 95.2ns ± 3% 94.7ns ± 2% ~ (p=0.256 n=10+10)
BufferWrite/len1_x4-8 128ns ± 2% 127ns ± 2% ~ (p=0.197 n=10+10)
BufferWrite/len1_x8-8 173ns ± 1% 172ns ± 1% -0.52% (p=0.030 n=10+10)
BufferWrite/len1_x16-8 269ns ± 1% 261ns ± 1% -2.94% (p=0.000 n=10+9)
BufferWrite/len8_x1-8 97.8ns ± 1% 95.7ns ± 2% -2.22% (p=0.000 n=10+10)
BufferWrite/len8_x4-8 128ns ± 1% 129ns ± 2% ~ (p=0.725 n=10+10)
BufferWrite/len8_x8-8 172ns ± 2% 173ns ± 2% ~ (p=0.225 n=10+10)
BufferWrite/len8_x16-8 424ns ± 1% 429ns ± 1% +1.32% (p=0.000 n=9+10)
BufferWrite/len16_x1-8 97.6ns ± 2% 96.2ns ± 2% -1.39% (p=0.029 n=10+10)
package gorules
import "github.com/quasilyte/go-ruleguard/dsl/fluent"
func useMathBits(m fluent.Matcher) {
m.Match(`$X >> $N | $X << (8 - $N)`,
`$X << $N | $X >> (8 - $N)`,
`$X >> (8 - $N) | $X << $N`,
`$X << (8 - $N) | $X >> $N`,
`$X >> $N | $X << (16 - $N)`,
Parser test cases:
// Empty pattern.
{``, `{}`},
// Anchors.
{`^`, `^`},
{`^^`, `{^ ^}`},
{`$`, `$`},
{`$$`, `{$ $}`},
"".getID1 STEXT size=169 args=0x10 locals=0x88
0x0000 00000 (arrcopy.go:10) TEXT "".getID1(SB), ABIInternal, $136-16
0x0000 00000 (arrcopy.go:10) MOVQ (TLS), CX
0x0009 00009 (arrcopy.go:10) LEAQ -8(SP), AX
0x000e 00014 (arrcopy.go:10) CMPQ AX, 16(CX)
0x0012 00018 (arrcopy.go:10) JLS 159
0x0018 00024 (arrcopy.go:10) SUBQ $136, SP
0x001f 00031 (arrcopy.go:10) MOVQ BP, 128(SP)
0x0027 00039 (arrcopy.go:10) LEAQ 128(SP), BP
0x002f 00047 (arrcopy.go:10) FUNCDATA $0, gclocals·33cdeccccebe80329f1fdbee7f5874cb(SB)