Skip to content

Instantly share code, notes, and snippets.

View quasilyte's full-sized avatar
🕵️

quasilyte quasilyte

🕵️
View GitHub Profile
Parser test cases:
// Empty pattern.
{``, `{}`},
// Anchors.
{`^`, `^`},
{`^^`, `{^ ^}`},
{`$`, `$`},
{`$$`, `{$ $}`},
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)`,
@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)
@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 / 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
package main
import "sync"
// Запустите с помощью "go run -race datarace.go".
var globalX int
func main() {
var wg sync.WaitGroup
@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.
@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
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