-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
dev: add targets to benchmark a linter #4761
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9146268
dev: add targets to benchmark a linter
ldez ce82ab8
dev: naming and trap
ldez df7011b
dev: linting and factorization
ldez b873a36
dev: fix prepare
ldez 8544791
dev: hide the script calls
ldez 34a0e3e
review: check hyperfine installation
ldez 314611b
review
ldez 467e7ac
review: check parameters
ldez 8e23556
review: be protected against everything
ldez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/bin/bash -e | ||
|
||
# Benchmark with a local version | ||
# Usage: ./scripts/bench/bench_local.sh gosec v1.59.0 | ||
|
||
# ex: gosec | ||
LINTER=$1 | ||
|
||
# ex: v1.59.0 | ||
VERSION=$2 | ||
|
||
|
||
if [ -z "$LINTER" ] || [ -z "$VERSION" ]; then | ||
cat <<-EOF | ||
Missing required arguments! | ||
|
||
Usage: $0 <linter> <old version> <new version> | ||
Example: $0 gosec v1.58.1 v1.58.2 | ||
EOF | ||
|
||
exit 1 | ||
fi | ||
|
||
EOF | ||
|
||
## Clean | ||
|
||
function cleanBinaries() { | ||
echo "Clean binaries" | ||
rm "./golangci-lint-${VERSION}" | ||
rm ./golangci-lint | ||
} | ||
|
||
trap cleanBinaries EXIT | ||
|
||
## Download version | ||
|
||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "./temp-${VERSION}" "${VERSION}" | ||
|
||
mv "temp-${VERSION}/golangci-lint" "./golangci-lint-${VERSION}" | ||
rm -rf "temp-${VERSION}" | ||
|
||
## Build local version | ||
|
||
make build | ||
|
||
## Run | ||
|
||
hyperfine \ | ||
--prepare './golangci-lint cache clean' "./golangci-lint run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" \ | ||
--prepare "./golangci-lint-${VERSION} cache clean" "./golangci-lint-${VERSION} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash -e | ||
|
||
# Benchmark between 2 existing versions | ||
# Usage: ./scripts/bench/bench_version.sh gosec v1.58.1 v1.58.2 | ||
|
||
# ex: gosec | ||
LINTER="$1" | ||
|
||
# ex: v1.58.1 | ||
VERSION_OLD="$2" | ||
# ex: v1.58.2 | ||
VERSION_NEW="$3" | ||
ldez marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
if [ -z "$LINTER" ] || [ -z "$VERSION_OLD" ] || [ -z "$VERSION_NEW" ]; then | ||
cat <<-EOF | ||
Missing required arguments! | ||
|
||
Usage: $0 <linter> <old version> <new version> | ||
Example: $0 gosec v1.58.1 v1.58.2 | ||
EOF | ||
|
||
exit 1 | ||
fi | ||
|
||
EOF | ||
|
||
## Clean | ||
|
||
function cleanBinaries() { | ||
echo "Clean binaries" | ||
rm "./golangci-lint-${VERSION_OLD}" | ||
rm "./golangci-lint-${VERSION_NEW}" | ||
} | ||
|
||
trap cleanBinaries EXIT | ||
|
||
## Install | ||
|
||
function install() { | ||
local VERSION=$1 | ||
|
||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "./temp-${VERSION}" "${VERSION}" | ||
|
||
mv "temp-${VERSION}/golangci-lint" "./golangci-lint-${VERSION}" | ||
rm -rf "temp-${VERSION}" | ||
} | ||
|
||
## VERSION_OLD | ||
|
||
install "${VERSION_OLD}" | ||
|
||
## VERSION_NEW | ||
|
||
install "${VERSION_NEW}" | ||
|
||
## Run | ||
|
||
hyperfine \ | ||
--prepare "./golangci-lint-${VERSION_OLD} cache clean" "./golangci-lint-${VERSION_OLD} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" \ | ||
--prepare "./golangci-lint-${VERSION_NEW} cache clean" "./golangci-lint-${VERSION_NEW} run --issues-exit-code 0 --print-issued-lines=false --enable-only ${LINTER}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Benchmarks | ||
|
||
The script use [Hyperfine](https://github.com/sharkdp/hyperfine) to benchmark the command line of golangci-lint. | ||
|
||
## Benchmark one linter: with a local version | ||
|
||
```bash | ||
make bench_local LINTER=gosec VERSION=v1.59.0 | ||
``` | ||
|
||
## Benchmark one linter: between 2 existing versions | ||
|
||
```bash | ||
make bench_version LINTER=gosec VERSION_OLD=v1.58.1 VERSION_NEW=v1.59.0 | ||
``` |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.