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

Add Missing Parallel Benchmarks for Mustache Engine #346

Merged
merged 2 commits into from
Feb 22, 2024
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
9 changes: 8 additions & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,17 @@ jobs:
- name: Save Benchmark Results
uses: benchmark-action/github-action-benchmark@v1.19.3
with:
tool: "go"
# What benchmark tool the output.txt came from
tool: 'go'
# Where the output from the benchmark tool is stored
output-file-path: output.txt
# Where the previous data file is stored
external-data-json-path: ./cache/benchmark-data.json
# Secret for Github
github-token: ${{ secrets.BENCHMARK_TOKEN }}
# Directory that contains benchmark files on the GitHub pages branch
benchmark-data-dir-path: "benchmarks"
# Workflow will fail when an alert happens
fail-on-alert: true
comment-on-alert: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
#summary-always: ${{ github.event_name != 'push' && github.event_name != 'workflow_dispatch' }}
Expand Down
8 changes: 4 additions & 4 deletions ace/ace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func Benchmark_Ace_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -276,7 +276,7 @@ func Benchmark_Ace_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -290,7 +290,7 @@ func Benchmark_Ace_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -305,7 +305,7 @@ func Benchmark_Ace_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
8 changes: 4 additions & 4 deletions amber/amber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func Benchmark_Amber_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -257,7 +257,7 @@ func Benchmark_Amber_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -271,7 +271,7 @@ func Benchmark_Amber_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -286,7 +286,7 @@ func Benchmark_Amber_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
8 changes: 4 additions & 4 deletions handlebars/handlebars_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func Benchmark_Handlebars_Parallel(b *testing.B) {
// Note we don't register isAdmin again because handlebars does not support re-registering helpers
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -257,7 +257,7 @@ func Benchmark_Handlebars_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -272,7 +272,7 @@ func Benchmark_Handlebars_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -287,7 +287,7 @@ func Benchmark_Handlebars_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
8 changes: 4 additions & 4 deletions html/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ func Benchmark_Html_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -349,7 +349,7 @@ func Benchmark_Html_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -363,7 +363,7 @@ func Benchmark_Html_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -378,7 +378,7 @@ func Benchmark_Html_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
8 changes: 4 additions & 4 deletions jet/jet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func Benchmark_Jet_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -249,7 +249,7 @@ func Benchmark_Jet_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -263,7 +263,7 @@ func Benchmark_Jet_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -278,7 +278,7 @@ func Benchmark_Jet_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
35 changes: 35 additions & 0 deletions mustache/mustache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,38 @@ func Benchmark_Mustache(b *testing.B) {
}
})
}

func Benchmark_Mustache_Parallel(b *testing.B) {
expectSimple := `<h1>Hello, Parallel!</h1>`
engine := New("./views", ".mustache")
require.NoError(b, engine.Load())

b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
for pb.Next() {
var buf bytes.Buffer
//nolint:gosec,errcheck // Return value not needed for benchmark
_ = engine.Render(&buf, "simple", map[string]interface{}{
"Title": "Hello, Parallel!",
})
}
})
})

b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
for pb.Next() {
var buf bytes.Buffer
err := engine.Render(&buf, "simple", map[string]interface{}{
"Title": "Hello, Parallel!",
})
require.NoError(bb, err)
require.Equal(bb, expectSimple, trim(buf.String()))
}
})
})
}
8 changes: 4 additions & 4 deletions pug/pug_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func Benchmark_Pug_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -270,7 +270,7 @@ func Benchmark_Pug_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended", func(bb *testing.B) {
b.Run("extended", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -284,7 +284,7 @@ func Benchmark_Pug_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -299,7 +299,7 @@ func Benchmark_Pug_Parallel(b *testing.B) {
})
})

b.Run("parallel_extended_asserted", func(bb *testing.B) {
b.Run("extended_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
4 changes: 2 additions & 2 deletions slim/slim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func Benchmark_Slim_Parallel(b *testing.B) {
})
require.NoError(b, engine.Load())

b.Run("parallel_simple", func(bb *testing.B) {
b.Run("simple", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand All @@ -233,7 +233,7 @@ func Benchmark_Slim_Parallel(b *testing.B) {
})
})

b.Run("parallel_simple_asserted", func(bb *testing.B) {
b.Run("simple_asserted", func(bb *testing.B) {
bb.ReportAllocs()
bb.ResetTimer()
bb.RunParallel(func(pb *testing.PB) {
Expand Down
Loading