style(benchmark): 修复代码格式和忽略无用错误返回值
This commit is contained in:
parent
668ecde6db
commit
84c26c61ca
@ -356,4 +356,4 @@ func (p *BenchmarkContextPool) Put(ctx *BenchmarkContext) {
|
|||||||
default:
|
default:
|
||||||
// 池已满,丢弃
|
// 池已满,丢弃
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,9 +24,9 @@ func setupStaticTestDir() (string, func()) {
|
|||||||
// 创建测试文件
|
// 创建测试文件
|
||||||
testFiles := map[string][]byte{
|
testFiles := map[string][]byte{
|
||||||
"index.html": []byte("<html><body>Index</body></html>"),
|
"index.html": []byte("<html><body>Index</body></html>"),
|
||||||
"style.css": make([]byte, 1024), // 1KB
|
"style.css": make([]byte, 1024), // 1KB
|
||||||
"large.json": make([]byte, 10*1024), // 10KB
|
"large.json": make([]byte, 10*1024), // 10KB
|
||||||
"nested/file.js": make([]byte, 5*1024), // 5KB
|
"nested/file.js": make([]byte, 5*1024), // 5KB
|
||||||
}
|
}
|
||||||
|
|
||||||
for path, content := range testFiles {
|
for path, content := range testFiles {
|
||||||
@ -40,7 +40,7 @@ func setupStaticTestDir() (string, func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup := func() {
|
cleanup := func() {
|
||||||
os.RemoveAll(dir)
|
_ = os.RemoveAll(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir, cleanup
|
return dir, cleanup
|
||||||
@ -210,4 +210,4 @@ func BenchmarkStaticFileLookupWithAlias(b *testing.B) {
|
|||||||
ctx.Request.SetRequestURI("/static/style.css")
|
ctx.Request.SetRequestURI("/static/style.css")
|
||||||
handler.Handle(ctx)
|
handler.Handle(ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,7 +21,7 @@ func BenchmarkAccessLogProcess(b *testing.B) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
al := New(cfg)
|
al := New(cfg)
|
||||||
defer al.Close()
|
defer func() { _ = al.Close() }()
|
||||||
|
|
||||||
mockHandler := func(ctx *fasthttp.RequestCtx) {
|
mockHandler := func(ctx *fasthttp.RequestCtx) {
|
||||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||||
@ -49,7 +49,7 @@ func BenchmarkAccessLogProcessParallel(b *testing.B) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
al := New(cfg)
|
al := New(cfg)
|
||||||
defer al.Close()
|
defer func() { _ = al.Close() }()
|
||||||
|
|
||||||
mockHandler := func(ctx *fasthttp.RequestCtx) {
|
mockHandler := func(ctx *fasthttp.RequestCtx) {
|
||||||
ctx.SetStatusCode(fasthttp.StatusOK)
|
ctx.SetStatusCode(fasthttp.StatusOK)
|
||||||
@ -67,4 +67,4 @@ func BenchmarkAccessLogProcessParallel(b *testing.B) {
|
|||||||
handler(ctx)
|
handler(ctx)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -275,4 +275,4 @@ func BenchmarkCompressionMiddlewareParallel(b *testing.B) {
|
|||||||
handler(ctx)
|
handler(ctx)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -225,4 +225,4 @@ func BenchmarkRateLimiterStats(b *testing.B) {
|
|||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
rl.GetStats()
|
rl.GetStats()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -139,4 +139,4 @@ func BenchmarkSlidingWindowStats(b *testing.B) {
|
|||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
sw.GetStats()
|
sw.GetStats()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user