Fix benchmark so the buffer is read each time.
authorNoah Campbell <noahcampbell@gmail.com>
Tue, 20 Aug 2013 23:56:18 +0000 (16:56 -0700)
committerNoah Campbell <noahcampbell@gmail.com>
Fri, 23 Aug 2013 21:16:37 +0000 (14:16 -0700)
The bytes.Buffer was exhausted after the first read.  Creating a new
reader each invocation catpures the correctly timing.

hugolib/benchmark_test.go

index 31e58a14aa68a72f36765a90d0167f76971934eb..a3408896d6c9d14e24c62aa07830ab5c4878fb43 100644 (file)
@@ -12,7 +12,8 @@ func BenchmarkParsePage(b *testing.B) {
        sample.ReadFrom(f)
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
-               ReadFrom(sample, "bench")
+               p, _ := ReadFrom(bytes.NewReader(sample.Bytes()), "bench")
+               p = p
        }
 }