Skip to content

Commit ff3fe96

Browse files
committed
wip: squash go-runner
1 parent 98a5297 commit ff3fe96

File tree

77 files changed

+7081
-14
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+7081
-14
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go-runner/testdata/raw_results/*.json filter=lfs diff=lfs merge=lfs -text

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
workflow_dispatch:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
submodules: true
15+
- uses: actions/setup-go@v5
16+
- uses: moonrepo/setup-rust@v1
17+
with:
18+
components: rustfmt, clippy
19+
- uses: pre-commit/[email protected]
20+
with:
21+
extra_args: --all-files
22+
23+
tests:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
with:
28+
lfs: true
29+
submodules: true
30+
- uses: moonrepo/setup-rust@v1
31+
- run: |
32+
cd go-runner
33+
cargo test --all
34+
35+
36+
compat-integration-test-walltime:
37+
runs-on: codspeed-macro
38+
steps:
39+
- uses: actions/checkout@v4
40+
with:
41+
submodules: true
42+
- uses: actions/setup-go@v5
43+
- uses: moonrepo/setup-rust@v1
44+
with:
45+
cache-target: release
46+
47+
- name: Run the benchmarks
48+
uses: CodSpeedHQ/action@main
49+
with:
50+
working-directory: example
51+
run: cargo r --manifest-path ../go-runner/Cargo.toml -- test -bench=.
52+
53+
check:
54+
runs-on: ubuntu-latest
55+
if: always()
56+
needs:
57+
- lint
58+
- tests
59+
- compat-integration-test-walltime
60+
steps:
61+
- uses: re-actors/alls-green@release/v1
62+
with:
63+
jobs: ${{ toJson( needs ) }}

.gitmodules

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
[submodule "go-runner/testdata/projects/fzf"]
2+
path = go-runner/testdata/projects/fzf
3+
url = https://github.com/junegunn/fzf
4+
[submodule "go-runner/testdata/projects/opentelemetry-go"]
5+
path = go-runner/testdata/projects/opentelemetry-go
6+
url = https://github.com/open-telemetry/opentelemetry-go
7+
[submodule "go-runner/testdata/projects/golang-benchmarks"]
8+
path = go-runner/testdata/projects/golang-benchmarks
9+
url = https://github.com/SimonWaldherr/golang-benchmarks
10+
[submodule "go-runner/testdata/projects/fuego"]
11+
path = go-runner/testdata/projects/fuego
12+
url = https://github.com/go-fuego/fuego
13+
[submodule "go-runner/testdata/projects/hugo"]
14+
path = go-runner/testdata/projects/hugo
15+
url = https://github.com/gohugoio/hugo/
16+
[submodule "go-runner/testdata/projects/zerolog"]
17+
path = go-runner/testdata/projects/zerolog
18+
url = https://github.com/rs/zerolog
19+
[submodule "go-runner/testdata/projects/zap"]
20+
path = go-runner/testdata/projects/zap
21+
url = https://github.com/uber-go/zap
22+
[submodule "go-runner/testdata/projects/cli-runtime"]
23+
path = go-runner/testdata/projects/cli-runtime
24+
url = https://github.com/kubernetes/cli-runtime

.pre-commit-config.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,33 @@ repos:
66
- id: end-of-file-fixer
77
- id: check-yaml
88
- id: check-json
9+
exclude: ^go-runner/testdata/
910
- id: check-merge-conflict
1011
- id: check-added-large-files
12+
13+
- repo: https://github.com/doublify/pre-commit-rust
14+
rev: v1.0
15+
hooks:
16+
- id: fmt
17+
args: [--all, --]
18+
files: ^go-runner/
19+
pass_filenames: false
20+
additional_dependencies: []
21+
entry: bash -c 'cd go-runner && cargo fmt --all'
22+
language: system
23+
24+
- id: cargo-check
25+
args: [--all-targets]
26+
files: ^go-runner/
27+
pass_filenames: false
28+
additional_dependencies: []
29+
entry: bash -c 'cd go-runner && cargo check --all-targets'
30+
language: system
31+
32+
- id: clippy
33+
args: [--all-targets, --, -D, warnings]
34+
files: ^go-runner/
35+
pass_filenames: false
36+
additional_dependencies: []
37+
entry: bash -c 'cd go-runner && cargo clippy --all-targets -- -D warnings'
38+
language: system

example/fib_test.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,30 @@
11
package example
22

3-
import testing "github.com/CodSpeedHQ/codspeed-go/compat/testing"
3+
import "testing"
44

55
func BenchmarkFibonacci10(b *testing.B) {
6-
for i := 0; i < b.N; i++ {
7-
fibonacci(10)
8-
}
6+
b.Run("fibonacci(10)", func(b *testing.B) {
7+
b.Run("fibonacci(10)", func(b *testing.B) {
8+
for i := 0; i < b.N; i++ {
9+
fibonacci(10)
10+
}
11+
})
912

10-
b.Run("fibonacci(40)", func(b *testing.B) {
11-
for i := 0; i < b.N; i++ {
12-
fibonacci(10)
13-
}
1413
})
1514
}
1615

17-
func BenchmarkFibonacci20(b *testing.B) {
16+
func BenchmarkFibonacci20_Loop(b *testing.B) {
1817
for b.Loop() {
1918
fibonacci(20)
2019
}
2120
}
2221

22+
func BenchmarkFibonacci20_bN(b *testing.B) {
23+
for i := 0; i < b.N; i++ {
24+
fibonacci(20)
25+
}
26+
}
27+
2328
func BenchmarkFibonacci30(b *testing.B) {
2429
b.Run("fibonacci(30)", func(b *testing.B) {
2530
b.Run("fibonacci(30)", func(b *testing.B) {

example/go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
module example
22

33
go 1.24.3
4-
5-
require github.com/CodSpeedHQ/codspeed-go v0.0.0
6-
7-
replace github.com/CodSpeedHQ/codspeed-go => ..

example/sleep_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package example
2+
3+
import (
4+
"testing"
5+
"time"
6+
)
7+
8+
func busyWait(duration time.Duration) {
9+
start := time.Now()
10+
for time.Since(start) < duration {
11+
// Busy wait loop
12+
}
13+
}
14+
15+
func BenchmarkSleep100ns(b *testing.B) {
16+
for i := 0; i < b.N; i++ {
17+
busyWait(100 * time.Nanosecond)
18+
}
19+
}
20+
21+
func BenchmarkSleep1us(b *testing.B) {
22+
for i := 0; i < b.N; i++ {
23+
busyWait(1 * time.Microsecond)
24+
}
25+
}
26+
27+
func BenchmarkSleep10us(b *testing.B) {
28+
for i := 0; i < b.N; i++ {
29+
busyWait(10 * time.Microsecond)
30+
}
31+
}
32+
33+
func BenchmarkSleep100us(b *testing.B) {
34+
for i := 0; i < b.N; i++ {
35+
busyWait(100 * time.Microsecond)
36+
}
37+
}
38+
39+
func BenchmarkSleep1ms(b *testing.B) {
40+
for i := 0; i < b.N; i++ {
41+
busyWait(1 * time.Millisecond)
42+
}
43+
}
44+
45+
func BenchmarkSleep10ms(b *testing.B) {
46+
for i := 0; i < b.N; i++ {
47+
busyWait(10 * time.Millisecond)
48+
}
49+
}
50+
51+
func BenchmarkSleep50ms(b *testing.B) {
52+
for i := 0; i < b.N; i++ {
53+
busyWait(50 * time.Millisecond)
54+
}
55+
}

go-runner/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build-*/
2+
target/
3+
.codspeed

0 commit comments

Comments
 (0)