Reduce pre allocated memory, fix Etag benchmark, cleanup unused stuff

pull/402/head
ReneWerner87 2020-05-23 14:56:52 +02:00
parent 071fec42fe
commit b81126d3d7
2 changed files with 5 additions and 18 deletions

View File

@ -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)))
}

View File

@ -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