Skip to content

Commit

Permalink
add bench check on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Aug 11, 2024
1 parent 7579b9c commit 5b5c7ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/benchmark-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ jobs:
${{ runner.os }}-go-
- name: Benchmark sonic
run: sh scripts/bench.sh
run: |
export SONIC_NO_ASYNC_GC=1
export SONIC_BENCH_SINGLE=1
./scripts/bench.py -c -t 0.05 "go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Encoder|Decoder)_(Generic|Binding)_Sonic' ./..."
./scripts/bench.py -c -t 0.05 "go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Get|Set)One_Sonic|BenchmarkParseSeven_Sonic' ./ast"
cd ./generic_test
../scripts/bench.py -c -t 0.05 "go test -run ^$ -count=10 -benchmem -bench 'Benchmark' ."
10 changes: 10 additions & 0 deletions generic_test/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
var (
validFlag = os.Getenv("SONIC_VALID_GENERIC_BENCH") != ""
pretouchFlag = os.Getenv("SONIC_NO_PRETOUCH_BENCH") == ""
benchSingle = os.Getenv("SONIC_BENCH_SINGLE") != ""
)

type jsonLibEntry struct {
Expand All @@ -51,6 +52,15 @@ var jsonLibs = []jsonLibEntry {
{"JsonIterStd", jsoniter.ConfigCompatibleWithStandardLibrary.Marshal, jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal},
}

func init() {
if benchSingle {
jsonLibs = []jsonLibEntry {
{"Sonic", sonic.Marshal, sonic.Unmarshal},
{"SonicStd", sonic.ConfigStd.Marshal, sonic.ConfigStd.Unmarshal},
}
}
}

func BenchmarkUnmarshalConcrete(b *testing.B) {
runUnmarshalC(b)
}
Expand Down

0 comments on commit 5b5c7ee

Please sign in to comment.