Browse Source

Improvements (#5700)

Sergio Andrés Virviescas Santana 5 years ago
parent
commit
e58faf92b7

+ 0 - 1
frameworks/Go/fasthttp/README.md

@@ -11,5 +11,4 @@ This is the go portion of a [benchmarking test suite](https://www.techempower.co
     http://localhost:8080/db
     http://localhost:8080/db
     http://localhost:8080/queries?queries=[1-500]
     http://localhost:8080/queries?queries=[1-500]
     http://localhost:8080/fortune
     http://localhost:8080/fortune
-    http://localhost:8080/fortune-quick
     http://localhost:8080/update?queries=[1-500]
     http://localhost:8080/update?queries=[1-500]

+ 2 - 2
frameworks/Go/fasthttp/benchmark_config.json

@@ -133,7 +133,7 @@
         "versus": "go"
         "versus": "go"
       },
       },
       "quicktemplate": {
       "quicktemplate": {
-        "fortune_url": "/fortune-quick",
+        "fortune_url": "/fortune",
         "port": 8080,
         "port": 8080,
         "approach": "Realistic",
         "approach": "Realistic",
         "classification": "Platform",
         "classification": "Platform",
@@ -151,7 +151,7 @@
         "versus": "go"
         "versus": "go"
       },
       },
       "prefork-quicktemplate": {
       "prefork-quicktemplate": {
-        "fortune_url": "/fortune-quick",
+        "fortune_url": "/fortune",
         "port": 8080,
         "port": 8080,
         "approach": "Realistic",
         "approach": "Realistic",
         "classification": "Platform",
         "classification": "Platform",

+ 1 - 1
frameworks/Go/fasthttp/fasthttp-prefork-quicktemplate.dockerfile

@@ -12,4 +12,4 @@ RUN go generate ./templates
 RUN easyjson -pkg
 RUN easyjson -pkg
 RUN go build -ldflags="-s -w" -o app .
 RUN go build -ldflags="-s -w" -o app .
 
 
-CMD ./app -prefork -db pgx
+CMD ./app -prefork -db pgx -quicktemplate

+ 1 - 1
frameworks/Go/fasthttp/fasthttp-quicktemplate.dockerfile

@@ -12,4 +12,4 @@ RUN go generate ./templates
 RUN easyjson -pkg
 RUN easyjson -pkg
 RUN go build -ldflags="-s -w" -o app .
 RUN go build -ldflags="-s -w" -o app .
 
 
-CMD ./app -db pgx
+CMD ./app -db pgx -quicktemplate

+ 10 - 8
frameworks/Go/fasthttp/src/main.go

@@ -15,7 +15,7 @@ import (
 )
 )
 
 
 var bindHost, jsonEncoder, dbDriver, dbConnectionString string
 var bindHost, jsonEncoder, dbDriver, dbConnectionString string
-var prefork bool
+var prefork, useQuickTemplate bool
 
 
 func init() {
 func init() {
 	// init flags
 	// init flags
@@ -24,6 +24,7 @@ func init() {
 	flag.StringVar(&jsonEncoder, "json_encoder", "none", "json encoder: none or easyjson or sjson")
 	flag.StringVar(&jsonEncoder, "json_encoder", "none", "json encoder: none or easyjson or sjson")
 	flag.StringVar(&dbDriver, "db", "none", "db connection driver [values: none or pgx or mongo]")
 	flag.StringVar(&dbDriver, "db", "none", "db connection driver [values: none or pgx or mongo]")
 	flag.StringVar(&dbConnectionString, "db_connection_string", "", "db connection string")
 	flag.StringVar(&dbConnectionString, "db_connection_string", "", "db connection string")
+	flag.BoolVar(&useQuickTemplate, "quicktemplate", false, "use quicktemplate")
 
 
 	flag.Parse()
 	flag.Parse()
 }
 }
@@ -58,7 +59,13 @@ func main() {
 	}
 	}
 
 
 	// init json encoders
 	// init json encoders
-	var jsonHandler, dbHandler, queriesHandler, updateHandler fasthttp.RequestHandler
+	var jsonHandler, dbHandler, queriesHandler, updateHandler, fortuneHandler fasthttp.RequestHandler
+
+	if useQuickTemplate {
+		fortuneHandler = handlers.FortuneQuickHandler(db)
+	} else {
+		fortuneHandler = handlers.FortuneHandler(db)
+	}
 
 
 	switch jsonEncoder {
 	switch jsonEncoder {
 	case "easyjson":
 	case "easyjson":
@@ -78,9 +85,6 @@ func main() {
 		updateHandler = handlers.UpdateHandler(db)
 		updateHandler = handlers.UpdateHandler(db)
 	}
 	}
 
 
-	fortunesHandler := handlers.FortuneHandler(db)
-	fortunesQuickHandler := handlers.FortuneQuickHandler(db)
-
 	handler := func(ctx *fasthttp.RequestCtx) {
 	handler := func(ctx *fasthttp.RequestCtx) {
 		switch gotils.B2S(ctx.Path()) {
 		switch gotils.B2S(ctx.Path()) {
 		case "/plaintext":
 		case "/plaintext":
@@ -92,9 +96,7 @@ func main() {
 		case "/queries":
 		case "/queries":
 			queriesHandler(ctx)
 			queriesHandler(ctx)
 		case "/fortune":
 		case "/fortune":
-			fortunesHandler(ctx)
-		case "/fortune-quick":
-			fortunesQuickHandler(ctx)
+			fortuneHandler(ctx)
 		case "/update":
 		case "/update":
 			updateHandler(ctx)
 			updateHandler(ctx)
 		default:
 		default: