Home / File/ benchmarks_test.go — gin Source File

benchmarks_test.go — gin Source File

Architecture documentation for benchmarks_test.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go GinCore Routing 1 imports 15 functions

Entity Profile

Dependency Diagram

graph LR
  a906a1e4_6c37_acec_ab79_73a64d55196f["benchmarks_test.go"]
  6b9ad13d_c776_a5f8_e8c7_1816de72cb86["template"]
  a906a1e4_6c37_acec_ab79_73a64d55196f --> 6b9ad13d_c776_a5f8_e8c7_1816de72cb86
  style a906a1e4_6c37_acec_ab79_73a64d55196f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2017 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package gin

import (
	"html/template"
	"net/http"
	"os"
	"testing"
)

func BenchmarkOneRoute(B *testing.B) {
	router := New()
	router.GET("/ping", func(c *Context) {})
	runRequest(B, router, http.MethodGet, "/ping")
}

func BenchmarkRecoveryMiddleware(B *testing.B) {
	router := New()
	router.Use(Recovery())
	router.GET("/", func(c *Context) {})
	runRequest(B, router, http.MethodGet, "/")
}

func BenchmarkLoggerMiddleware(B *testing.B) {
	router := New()
	router.Use(LoggerWithWriter(newMockWriter()))
	router.GET("/", func(c *Context) {})
	runRequest(B, router, http.MethodGet, "/")
}

func BenchmarkManyHandlers(B *testing.B) {
	router := New()
	router.Use(Recovery(), LoggerWithWriter(newMockWriter()))
	router.Use(func(c *Context) {})
	router.Use(func(c *Context) {})
	router.GET("/ping", func(c *Context) {})
	runRequest(B, router, http.MethodGet, "/ping")
}

func Benchmark5Params(B *testing.B) {
	DefaultWriter = os.Stdout
	router := New()
	router.Use(func(c *Context) {})
	router.GET("/param/:param1/:params2/:param3/:param4/:param5", func(c *Context) {})
	runRequest(B, router, http.MethodGet, "/param/path/to/parameter/john/12345")
}

func BenchmarkOneRouteJSON(B *testing.B) {
	router := New()
	data := struct {
		Status string `json:"status"`
	}{"ok"}
	router.GET("/json", func(c *Context) {
		c.JSON(http.StatusOK, data)
	})
	runRequest(B, router, http.MethodGet, "/json")
}
// ... (101 more lines)

Domain

Subdomains

Dependencies

  • template

Frequently Asked Questions

What does benchmarks_test.go do?
benchmarks_test.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Routing subdomain.
What functions are defined in benchmarks_test.go?
benchmarks_test.go defines 15 function(s): Benchmark404, Benchmark404Many, Benchmark5Params, BenchmarkLoggerMiddleware, BenchmarkManyHandlers, BenchmarkManyRoutesFirst, BenchmarkManyRoutesLast, BenchmarkOneRoute, BenchmarkOneRouteHTML, BenchmarkOneRouteJSON, and 5 more.
What does benchmarks_test.go depend on?
benchmarks_test.go imports 1 module(s): template.
Where is benchmarks_test.go in the architecture?
benchmarks_test.go is located at benchmarks_test.go (domain: GinCore, subdomain: Routing).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free