shithub: hugo

Download patch

ref: 8557e2cbb821663a5a482d904b031dff831b06cc
parent: ecb2aca6a2f75a703d64a88e30a8a11e2fe6eaac
author: bep <[email protected]>
date: Thu Mar 5 16:10:53 EST 2015

Add benchmark for the shortcode lexer

--- a/hugolib/shortcodeparser_test.go
+++ b/hugolib/shortcodeparser_test.go
@@ -126,12 +126,24 @@
 		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)
 		if !equal(items, test.items) {
 			t.Errorf("%s: got\n\t%v\nexpected\n\t%v", test.name, items, test.items)
+		}
+	}
+}
+
+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)
+			}
 		}
 	}
 }