Home / Function/ BenchmarkRequestHeapScan() — fiber Function Reference

BenchmarkRequestHeapScan() — fiber Function Reference

Architecture documentation for the BenchmarkRequestHeapScan() function in request_bench_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  14d2e56d_bef2_a9df_1c6b_0a0204bebb71["BenchmarkRequestHeapScan()"]
  21fe2c98_fc8d_efc8_6a15_e37ab0542e3c["request_bench_test.go"]
  14d2e56d_bef2_a9df_1c6b_0a0204bebb71 -->|defined in| 21fe2c98_fc8d_efc8_6a15_e37ab0542e3c
  style 14d2e56d_bef2_a9df_1c6b_0a0204bebb71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

client/request_bench_test.go lines 12–58

func BenchmarkRequestHeapScan(b *testing.B) {
	samples := []metrics.Sample{
		{Name: "/gc/scan/heap:bytes"},
		{Name: "/gc/scan/total:bytes"},
	}

	b.ReportAllocs()
	b.StopTimer()
	b.ResetTimer()

	const batchSize = 512
	var totalScanHeap, totalScanAll uint64
	for i := 0; i < b.N; i++ {
		reqs := make([]*Request, batchSize)
		// revive:disable-next-line:call-to-gc // Ensure consistent heap state before measuring scan metrics
		runtime.GC()
		metrics.Read(samples)
		startScanHeap := samples[0].Value.Uint64()
		startScanAll := samples[1].Value.Uint64()

		b.StartTimer()
		for j := range reqs {
			req := AcquireRequest()
			req.SetHeader("X-Benchmark", "value")
			req.SetCookie("session", strconv.Itoa(j))
			req.SetPathParam("id", strconv.Itoa(j))
			req.SetParam("page", strconv.Itoa(j))
			reqs[j] = req
		}
		b.StopTimer()

		// revive:disable-next-line:call-to-gc // Force GC to capture post-benchmark scan metrics
		runtime.GC()
		metrics.Read(samples)
		totalScanHeap += samples[0].Value.Uint64() - startScanHeap
		totalScanAll += samples[1].Value.Uint64() - startScanAll

		for _, req := range reqs {
			ReleaseRequest(req)
		}
	}

	if b.N > 0 {
		b.ReportMetric(float64(totalScanHeap)/float64(b.N), "scan-bytes-heap/op")
		b.ReportMetric(float64(totalScanAll)/float64(b.N), "scan-bytes-total/op")
	}
}

Domain

Subdomains

Frequently Asked Questions

What does BenchmarkRequestHeapScan() do?
BenchmarkRequestHeapScan() is a function in the fiber codebase, defined in client/request_bench_test.go.
Where is BenchmarkRequestHeapScan() defined?
BenchmarkRequestHeapScan() is defined in client/request_bench_test.go at line 12.

Analyze Your Own Codebase

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

Try Supermodel Free