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

two new scripts are added. benchmark.sh genreport_test.sh #158

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 2 additions & 0 deletions algname_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package goserbench
const ALG_NAME = "msgpack"
11 changes: 11 additions & 0 deletions benchmarks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
for f in `sed s://.*:: benchmarks.go |awk '/Name:/{print $2}'|sed s/[,]//g`; do
echo "package goserbench" > algname_test.go;
echo "const ALG_NAME = $f" >> algname_test.go;
go test -bench=. -benchmem| grep BenchmarkSerializers| sed s:BenchmarkSerializers/::;
done
echo "package goserbench" > algname_test.go;
echo "const ALG_NAME = \"any\"" >> algname_test.go;



3 changes: 3 additions & 0 deletions benchmarks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ See README.md for details on running the benchmarks.
func BenchmarkSerializers(b *testing.B) {
for i := range benchmarkCases {
bc := benchmarkCases[i]
if ALG_NAME != "any" && bc.Name != ALG_NAME {
continue
}
b.Run("marshal/"+bc.Name, func(b *testing.B) {
goserbench.BenchMarshalSmallStruct(b, bc.New())
})
Expand Down
3 changes: 3 additions & 0 deletions genreport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type reportLine struct {
func generateReport() error {
data := make([]reportLine, len(benchmarkCases))
for i, bench := range benchmarkCases {
if ALG_NAME != "any" && bench.Name != ALG_NAME {
continue
}
marshalRes := testing.Benchmark(func(b *testing.B) {
goserbench.BenchMarshalSmallStruct(b, bench.New())
})
Expand Down
22 changes: 22 additions & 0 deletions genreport_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
rm -f /tmp/temp_report.js
for f in `sed s://.*:: benchmarks.go |awk '/Name:/{print $2}'|sed s/[,]//g`; do
echo "package goserbench" > algname_test.go;
echo "const ALG_NAME = $f" >> algname_test.go;
go test -tags genreport -run TestGenerateReport
lines=`wc -l ./report/data.js|awk '{print $1;}'`
tail -$(($lines)) ./report/data.js|head -$(($lines-2)) >> /tmp/temp_report.js
echo -e "\t}," >> /tmp/temp_report.js
done

lines=`wc -l /tmp/temp_report.js|awk '{print $1;}'`
echo "var data = [" > report/data.js
head -$(($lines-2)) /tmp/temp_report.js >> ./report/data.js
echo -e "\t}" >> ./report/data.js
echo -n "];" >> ./report/data.js
rm -f /tmp/temp_report.js


echo "package goserbench" > algname_test.go;
echo "const ALG_NAME = \"any\"" >> algname_test.go;