bench_test.go 496 B

123456789101112131415161718192021
  1. // Copyright 2012 The Gorilla Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package mux
  5. import (
  6. "net/http"
  7. "testing"
  8. )
  9. func BenchmarkMux(b *testing.B) {
  10. router := new(Router)
  11. handler := func(w http.ResponseWriter, r *http.Request) {}
  12. router.HandleFunc("/v1/{v1}", handler)
  13. request, _ := http.NewRequest("GET", "/v1/anything", nil)
  14. for i := 0; i < b.N; i++ {
  15. router.ServeHTTP(nil, request)
  16. }
  17. }