From 5c06e6b6bb2db50fbe6cf297365253433388c00f Mon Sep 17 00:00:00 2001 From: phuslu Date: Thu, 21 Mar 2024 10:34:37 +0800 Subject: [PATCH] split github workflows --- .github/workflows/benchmark.yml | 21 ----------------- .github/workflows/memory.yml | 40 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 19 ++++++++++++++++ 3 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/memory.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index dfbc2eb..fbd166c 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -11,8 +11,6 @@ jobs: benchmark: runs-on: ubuntu-latest steps: - - name: Install packages - run: sudo apt update -y && sudo apt-get install -y csvkit datamash - uses: actions/setup-go@v4 with: go-version: '1.22' @@ -27,27 +25,8 @@ jobs: go mod tidy go mod edit -replace github.com/phuslu/lru=../ cat go.mod - - name: Tests - run: | - go test -v -bench=. -race -count=1 -coverprofile=coverage.txt - name: Throughput benchmarks working-directory: ./bench run: | env writeratio=0.1 zipfian=false go test -v -cpu=8 -run=none -bench=. -benchtime=5s -benchmem bench_test.go env writeratio=0.01 zipfian=true go test -v -cpu=8 -run=none -bench=. -benchtime=5s -benchmem bench_test.go - - name: Memory Usage - working-directory: ./bench - run: | - awk '{if($0 ~ "// memusage.go"){a=1;b=1};if($0 ~ "```" && b=1){b=0};if (a&&b) {print}}' ../README.md > memusage.go - echo -e 'MemStats\tCacheSize\tAlloc\tTotalAlloc\tSys' > memusage.txt - for name in nottl phuslu lxzan ristretto freelru ecache otter theine cloudflare ccache hashicorp; do - for cachesize in 100000 200000 400000 1000000 2000000 4000000; do - go run memusage.go $name $cachesize >> memusage.txt - done - done - cat memusage.txt - cat memusage.txt | datamash --header-in crosstab 1,2 unique 3 | tee >(head -1) | tail -n +2 | sort -k12 -n | datamash transpose | tee >(head -1) | tail -n +2 | sort -n | datamash transpose | csvlook - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/memory.yml b/.github/workflows/memory.yml new file mode 100644 index 0000000..843042e --- /dev/null +++ b/.github/workflows/memory.yml @@ -0,0 +1,40 @@ +name: benchmark + +on: + schedule: + - cron: '0 0 * * *' + push: + branches: + - master + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - name: Install packages + run: sudo apt update -y && sudo apt-get install -y csvkit datamash + - uses: actions/setup-go@v4 + with: + go-version: '1.22' + check-latest: true + - uses: actions/checkout@v4 + - name: go mod tidy + run: | + mkdir bench + cd bench + awk '{if($0 ~ "// memusage.go"){a=1;b=1};if($0 ~ "```" && b=1){b=0};if (a&&b) {print}}' ../README.md > memusage.go + go mod init bench + go mod tidy + go mod edit -replace github.com/phuslu/lru=../ + cat go.mod + - name: Memory Usage + working-directory: ./bench + run: | + echo -e 'MemStats\tCacheSize\tAlloc\tTotalAlloc\tSys' > memusage.txt + for name in nottl phuslu lxzan ristretto freelru ecache otter theine cloudflare ccache hashicorp; do + for cachesize in 100000 200000 400000 1000000 2000000 4000000; do + go run memusage.go $name $cachesize >> memusage.txt + done + done + cat memusage.txt + cat memusage.txt | datamash --header-in crosstab 1,2 unique 3 | tee >(head -1) | tail -n +2 | sort -k12 -n | datamash transpose | tee >(head -1) | tail -n +2 | sort -n | datamash transpose | csvlook diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..a97206e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: test + +on: + push: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Tests + run: | + go test -v -bench=. -race -count=1 -coverprofile=coverage.txt + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }}