From 4d8c2a2e19ca58d4a99aa1bb087e38b586070743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Nieto?= <jose.carlos@menteslibres.net> Date: Thu, 11 Sep 2014 21:36:04 -0500 Subject: [PATCH] Adding benchmarks --- util/sqlgen/benchmark_test.go | 59 +++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/util/sqlgen/benchmark_test.go b/util/sqlgen/benchmark_test.go index c9261c79..f04428ae 100644 --- a/util/sqlgen/benchmark_test.go +++ b/util/sqlgen/benchmark_test.go @@ -4,6 +4,62 @@ import ( "testing" ) +func BenchmarkColumn(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Column{"a"} + } +} + +func BenchmarkColumnNestedValue(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Column{Value: "a"} + } +} + +func BenchmarkCompileColumn(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Column{Value: "a"}.Compile(defaultTemplate) + } +} + +func BenchmarkValue(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Value{"a"} + } +} + +func BenchmarkValueRaw(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Value{Raw{"a"}} + } +} + +func BenchmarkColumnValue(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = ColumnValue{Column{"a"}, "=", Value{Raw{"7"}}} + } +} + +func BenchmarkTable(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Table{"foo"} + } +} + +func BenchmarkCompileTable(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Table{"foo"}.Compile(defaultTemplate) + } +} + +func BenchmarkWhere(b *testing.B) { + for i := 0; i < b.N; i++ { + _ = Where{ + ColumnValue{Column{"a"}, "=", Value{Raw{"7"}}}, + } + } +} + func BenchmarkCompileSelect(b *testing.B) { var stmt Statement @@ -15,7 +71,6 @@ func BenchmarkCompileSelect(b *testing.B) { ColumnValue{Column{"a"}, "=", Value{Raw{"7"}}}, }, } - stmt.Compile(defaultTemplate) + _ = stmt.Compile(defaultTemplate) } - } -- GitLab