| 75 | } |
| 76 | |
| 77 | func BenchmarkHTML(b *testing.B) { |
| 78 | render := New(Options{ |
| 79 | Directory: "testdata/basic", |
| 80 | }) |
| 81 | |
| 82 | h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { |
| 83 | _ = render.HTML(w, http.StatusOK, "hello", "gophers") |
| 84 | }) |
| 85 | req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "/foo", nil) |
| 86 | |
| 87 | b.ResetTimer() |
| 88 | b.RunParallel(func(pb *testing.PB) { |
| 89 | for pb.Next() { |
| 90 | h.ServeHTTP(httptest.NewRecorder(), req) |
| 91 | } |
| 92 | }) |
| 93 | } |
| 94 | |
| 95 | // Test Helpers. |
| 96 | func expect(t *testing.T, a interface{}, b interface{}) { |