Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Aug 12, 2024
1 parent e18df73 commit dbcc946
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/benchmark-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,26 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: Benchmark sonic
- name: Benchmark Target
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' ./decoder"
./scripts/bench.py -c -t 0.05 "go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Get|Set)One_Sonic|BenchmarkParseSeven_Sonic' ./ast"
./scripts/bench.py -c -t 0.05 "go test -run ^$ -count=10 -benchmem -bench 'Benchmark' ./generic_test"
go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Encoder|Decoder)_(Generic|Binding)_Sonic' ./decoder >> /var/tmp/sonic_bench_target.out
go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Get|Set)One_Sonic|BenchmarkParseSeven_Sonic' ./ast >> /var/tmp/sonic_bench_target.out
go test -run ^$ -count=5 -benchmem -bench 'Benchmark' ./generic_test >> /var/tmp/sonic_bench_target.out
- name: Checkout main
uses: actions/checkout@v2
with:
ref: main

- name: Benchmark main
run: |
export SONIC_NO_ASYNC_GC=1
export SONIC_BENCH_SINGLE=1
go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Encoder|Decoder)_(Generic|Binding)_Sonic' ./decoder >> /var/tmp/sonic_bench_main.out
go test -run ^$ -count=10 -benchmem -bench 'Benchmark(Get|Set)One_Sonic|BenchmarkParseSeven_Sonic' ./ast >> /var/tmp/sonic_bench_main.out
go test -run ^$ -count=5 -benchmem -bench 'Benchmark' ./generic_test >> /var/tmp/sonic_bench_main.out
- name: Diff bench
run: ./scripts/bench.py -t 0.05 -d /var/tmp/sonic_bench_target.out,/var/tmp/sonic_bench_main.out x
4 changes: 4 additions & 0 deletions scripts/bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,17 @@ def bench_diff(main, target, threshold=0.05):
def main():
argparser = argparse.ArgumentParser(description='Tools to test the performance. Example: ./bench.py "go test -bench=. ./..."')
argparser.add_argument('cmd', type=str, help='Golang benchmark command')
argparser.add_argument('-d', type=str, dest='diff', help='diff bench')
argparser.add_argument('-t', type=float, dest='threshold', default=0.1, help='diff bench threshold')
argparser.add_argument('-c', '--compare', dest='compare', action='store_true',
help='Compare the current branch with the main branch')
args = argparser.parse_args()

if args.compare:
compare(args)
elif args.diff:
target, base = args.diff.split(',')
bench_diff(target, base, args.threshold)
else:
run_bench(args, "target")

Expand Down

0 comments on commit dbcc946

Please sign in to comment.