Skip to content

Commit

Permalink
simpler benchmark. bump to go 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
magiconair committed Dec 8, 2022
1 parent 44ba29f commit dfe5f6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
go: ["1.19.x","1.18.x","1.5.x"] # keeping 1.5.x b/c we can. works with 1.3.x
go: ["1.19.x","1.18.x","1.7.x"] # code works with 1.3.x but we need 1.7.x for Benchmark.Run

steps:
- name: Setup Go ${{ matrix.go }}
Expand Down
25 changes: 13 additions & 12 deletions properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,19 +913,20 @@ func TestLoad(t *testing.T) {

// ----------------------------------------------------------------------------

var inputs = []struct {
input int
}{
{input: 1e2},
{input: 1e3},
{input: 1e4},
{input: 1e5},
}

// GOMAXPROCS=1 go test -run='^$' -bench '^BenchmarkMerge$' github.com/magiconair/properties
// goos: darwin
// goarch: arm64
// pkg: github.com/magiconair/properties
// BenchmarkMerge/num_properties_100 469435 2533 ns/op
// BenchmarkMerge/num_properties_1000 39649 29420 ns/op
// BenchmarkMerge/num_properties_10000 2786 427934 ns/op
// BenchmarkMerge/num_properties_100000 244 4749766 ns/op
// PASS
// ok github.com/magiconair/properties 6.842s
func BenchmarkMerge(b *testing.B) {
for _, v := range inputs {
p := generateProperties(v.input)
b.Run(fmt.Sprintf("num_properties_%d", v.input), func(b *testing.B) {
for _, n := range []int{1e2, 1e3, 1e4, 1e5} {
p := generateProperties(n)
b.Run(fmt.Sprintf("num_properties_%d", n), func(b *testing.B) {
for i := 0; i < b.N; i++ {
p.Merge(p)
}
Expand Down

0 comments on commit dfe5f6d

Please sign in to comment.