mirror of https://github.com/gofiber/fiber.git
Reduce pre allocated memory, fix Etag benchmark, cleanup unused stuff
parent
071fec42fe
commit
b81126d3d7
|
@ -323,5 +323,5 @@ func Benchmark_App_ETag_Weak(b *testing.B) {
|
|||
for n := 0; n < b.N; n++ {
|
||||
setETag(c, true)
|
||||
}
|
||||
utils.AssertEqual(b, `W/""13-1831710635""`, string(c.Fasthttp.Response.Header.Peek(HeaderETag)))
|
||||
utils.AssertEqual(b, `W/"13-1831710635"`, string(c.Fasthttp.Response.Header.Peek(HeaderETag)))
|
||||
}
|
||||
|
|
21
utils.go
21
utils.go
|
@ -232,14 +232,14 @@ func parseRoute(pattern string) (p routeParser) {
|
|||
}
|
||||
|
||||
// performance tricks
|
||||
var paramsDummy = make([]string, 10000000)
|
||||
var paramsPosDummy = make([][2]int, 10000000)
|
||||
var paramsDummy = make([]string, 100000)
|
||||
var paramsPosDummy = make([][2]int, 100000)
|
||||
var startParamList, startParamPosList uint32 = 0, 0
|
||||
|
||||
func getAllocFreeParamsPos(allocLen int) [][2]int {
|
||||
size := uint32(allocLen)
|
||||
start := atomic.AddUint32(&startParamPosList, size)
|
||||
if (start + 100) >= uint32(len(paramsPosDummy)) {
|
||||
if (start + 10) >= uint32(len(paramsPosDummy)) {
|
||||
atomic.StoreUint32(&startParamPosList, 0)
|
||||
return getAllocFreeParamsPos(allocLen)
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ func getAllocFreeParamsPos(allocLen int) [][2]int {
|
|||
func getAllocFreeParams(allocLen int) []string {
|
||||
size := uint32(allocLen)
|
||||
start := atomic.AddUint32(&startParamList, size)
|
||||
if (start + 100) >= uint32(len(paramsPosDummy)) {
|
||||
if (start + 10) >= uint32(len(paramsPosDummy)) {
|
||||
atomic.StoreUint32(&startParamList, 0)
|
||||
return getAllocFreeParams(allocLen)
|
||||
}
|
||||
|
@ -349,19 +349,6 @@ var methodINT = map[string]int{
|
|||
MethodPatch: 8,
|
||||
}
|
||||
|
||||
// unique INTs and the associated HTTP method
|
||||
// var intMethod = map[int]string{
|
||||
// 0: MethodGet,
|
||||
// 1: MethodHead,
|
||||
// 2: MethodPost,
|
||||
// 3: MethodPut,
|
||||
// 4: MethodDelete,
|
||||
// 5: MethodConnect,
|
||||
// 6: MethodOptions,
|
||||
// 7: MethodTrace,
|
||||
// 8: MethodPatch,
|
||||
// }
|
||||
|
||||
// HTTP methods were copied from net/http.
|
||||
const (
|
||||
MethodGet = "GET" // RFC 7231, 4.3.1
|
||||
|
|
Loading…
Reference in New Issue