From: bep <bjorn.erik.pedersen@gmail.com>
Date: Thu, 5 Mar 2015 20:10:53 +0000 (+0100)
Subject: Add benchmark for the shortcode lexer
X-Git-Tag: v0.14~234
X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=8557e2cbb821663a5a482d904b031dff831b06cc;p=brevno-suite%2Fhugo

Add benchmark for the shortcode lexer
---

diff --git a/hugolib/shortcodeparser_test.go b/hugolib/shortcodeparser_test.go
index 4485fa13..8ebb85d6 100644
--- a/hugolib/shortcodeparser_test.go
+++ b/hugolib/shortcodeparser_test.go
@@ -126,7 +126,7 @@ var shortCodeLexerTests = []shortCodeLexerTest{
 		item{tText, 0, "{{<"}, item{tText, 0, " sc1 >}}"}, {tError, 0, "comment ends before the right shortcode delimiter"}}},
 }
 
-func TestPagelexer(t *testing.T) {
+func TestShortcodeLexer(t *testing.T) {
 	for _, test := range shortCodeLexerTests {
 
 		items := collect(&test)
@@ -136,6 +136,18 @@ func TestPagelexer(t *testing.T) {
 	}
 }
 
+func BenchmarkShortcodeLexer(b *testing.B) {
+	b.ResetTimer()
+	for i := 0; i < b.N; i++ {
+		for _, test := range shortCodeLexerTests {
+			items := collect(&test)
+			if !equal(items, test.items) {
+				b.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, items, test.items)
+			}
+		}
+	}
+}
+
 func collect(t *shortCodeLexerTest) (items []item) {
 	l := newShortcodeLexer(t.name, t.input, 0)
 	for {