Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

msgpack: add benchmarks #93

Merged
merged 6 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Benchmark

on:
push:
branches: "*"
tags:
- "v*"
pull_request:
branches: "*"

defaults:
run:
shell: bash

jobs:
benchmark:
strategy:
matrix:
os:
# https://github.com/actions/virtual-environments/blob/ubuntu20/20201210.0/images/linux/Ubuntu2004-README.md
- ubuntu-20.04
go-version:
- 1.15.x
runs-on: ${{ matrix.os }}

steps:
- name: Set flag environment variable
run: |
echo "OS=$(echo ${{ runner.os }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
echo "GO_VERSION=$(echo ${{ matrix.go-version }} | cut -d. -f-2)" >> $GITHUB_ENV

- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- name: Checkout code
uses: actions/checkout@v2

- name: Cache Go module and build cache
uses: actions/cache@v2
with:
key: ${{ env.OS }}-go-${{ hashFiles('**/go.sum') }}
path: |
~/go/pkg/mod # Module download cache
~/.cache/go-build # Build cache (Linux)
restore-keys: |
${{ env.OS }}-go-

- name: Cache nvim binary for linux and darwin
uses: actions/cache@v2
id: cache-nvim
with:
key: ${{ env.OS }}-nvim-${{ hashFiles('~/nvim/bin/nvim') }}
path: |
~/nvim
restore-keys: |
${{ env.OS }}-nvim-

- name: Install nvim binary
uses: rhysd/action-setup-vim@v1
if: steps.cache-nvim.outputs.cache-hit != 'true'
with:
neovim: true
version: nightly

- name: Run Benchmark
run: |
go test -v -count=3 -run=none -bench=. -benchmem -timeout=15m ./... | tee bench-${{ env.OS }}-${{ env.GO_VERSION }}.txt

- name: 'Upload benchmark Artifact'
uses: actions/upload-artifact@v2
with:
name: bench-${{ env.OS }}-${{ env.GO_VERSION }}.txt
path: bench-${{ env.OS }}-${{ env.GO_VERSION }}.txt
8 changes: 0 additions & 8 deletions msgpack/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ type testDecArrayStruct struct {
S string
}

func ptrInt(i int) *int {
return &i
}

func ptrUint(i uint) *uint {
return &i
}

func TestDecode(t *testing.T) {
t.Parallel()

Expand Down
24 changes: 12 additions & 12 deletions msgpack/msgpack.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ const (
fixStringCodeMin = 0xa0
fixStringCodeMax = 0xbf
nilCode = 0xc0
unusedCode = 0xc1
unusedCode = 0xc1 // never used
falseCode = 0xc2
trueCode = 0xc3
binary8Code = 0xc4
binary16Code = 0xc5
binary32Code = 0xc6
ext8Code = 0xc7
ext16Code = 0xc8
ext32Code = 0xc9
float32Code = 0xca
float64Code = 0xcb
uint8Code = 0xcc
Expand All @@ -24,24 +30,18 @@ const (
int16Code = 0xd1
int32Code = 0xd2
int64Code = 0xd3
fixExt1Code = 0xd4
fixExt2Code = 0xd5
fixExt4Code = 0xd6
fixExt8Code = 0xd7
fixExt16Code = 0xd8
string8Code = 0xd9
string16Code = 0xda
string32Code = 0xdb
binary8Code = 0xc4
binary16Code = 0xc5
binary32Code = 0xc6
array16Code = 0xdc
array32Code = 0xdd
map16Code = 0xde
map32Code = 0xdf
fixext1Code = 0xd4
fixext2Code = 0xd5
fixext4Code = 0xd6
fixext8Code = 0xd7
fixext16Code = 0xd8
ext8Code = 0xc7
ext16Code = 0xc8
ext32Code = 0xc9
negFixIntCodeMin = 0xe0
negFixIntCodeMax = 0xff
)
Expand Down
Loading