Skip to content

Commit a896883

Browse files
committed
chore: add example using integration test
1 parent a88bf0f commit a896883

5 files changed

Lines changed: 73 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
runs-on: codspeed-macro
6868
strategy:
6969
matrix:
70-
target: [example, example/compat, example/timing, example/very/nested/module]
70+
target: [example, example/compat, example/timing, example/very/nested/module, example/external]
7171
steps:
7272
- uses: actions/checkout@v4
7373
with:

example/external/external_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This file uses the _test package suffix, which is a common Go pattern
2+
// for black-box testing. This tests the public API of the math package
3+
// without accessing internal implementation details.
4+
package external_test
5+
6+
import (
7+
"example"
8+
"testing"
9+
)
10+
11+
func BenchmarkExternalFib(b *testing.B) {
12+
for i := 0; i < b.N; i++ {
13+
example.Fibonacci(5)
14+
}
15+
}

example/fib.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ func fibonacci(n int) int {
66
}
77
return fibonacci(n-1) + fibonacci(n-2)
88
}
9+
10+
var Fibonacci = fibonacci

go-runner/src/builder/snapshots/codspeed_go_runner__builder__discovery__tests__discover_benchmarks@example.snap

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ expression: packages
149149
}
150150
]
151151
},
152+
{
153+
"raw_package": "[raw_package]",
154+
"benchmarks": [
155+
{
156+
"name": "BenchmarkAdd",
157+
"module_path": "example/external",
158+
"import_alias": "benchmarkadd_8141020470883116639",
159+
"qualified_name": "benchmarkadd_8141020470883116639.BenchmarkAdd",
160+
"file_path": "external/math_test.go",
161+
"is_external": true
162+
},
163+
{
164+
"name": "BenchmarkMultiply",
165+
"module_path": "example/external",
166+
"import_alias": "benchmarkmultiply_8141020470883116639",
167+
"qualified_name": "benchmarkmultiply_8141020470883116639.BenchmarkMultiply",
168+
"file_path": "external/math_test.go",
169+
"is_external": true
170+
}
171+
]
172+
},
152173
{
153174
"raw_package": "[raw_package]",
154175
"benchmarks": [

go-runner/src/snapshots/codspeed_go_runner__integration_tests__assert_results_snapshots@example.snap

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,40 @@ source: go-runner/src/integration_tests.rs
33
expression: results
44
---
55
[
6+
{
7+
"creator": {
8+
"name": "codspeed-go",
9+
"version": "[version]",
10+
"pid": "[pid]"
11+
},
12+
"instrument": {
13+
"type": "walltime"
14+
},
15+
"benchmarks": [
16+
{
17+
"name": "BenchmarkAdd",
18+
"uri": "example/external/codspeed/math_test.go::BenchmarkAdd",
19+
"config": {
20+
"warmup_time_ns": null,
21+
"min_round_time_ns": null,
22+
"max_time_ns": null,
23+
"max_rounds": null
24+
},
25+
"stats": "[stats]"
26+
},
27+
{
28+
"name": "BenchmarkMultiply",
29+
"uri": "example/external/codspeed/math_test.go::BenchmarkMultiply",
30+
"config": {
31+
"warmup_time_ns": null,
32+
"min_round_time_ns": null,
33+
"max_time_ns": null,
34+
"max_rounds": null
35+
},
36+
"stats": "[stats]"
37+
}
38+
]
39+
},
640
{
741
"creator": {
842
"name": "codspeed-go",

0 commit comments

Comments
 (0)