[sources] Add server-dummy simplified fasthttp benchmark target

This commit is contained in:
Ciprian Dorin Craciun 2019-08-12 14:01:15 +03:00
parent 1cc9d9bacb
commit 7a07668283
2 changed files with 51 additions and 0 deletions

View file

@ -536,3 +536,22 @@
#
!!
<< benchmark / dummy
test "${#}" -eq 0
_outputs="$( exec -- readlink -e -- ./.outputs )"
mkdir -p -- "${_outputs}/binaries/release"
"${ZRUN[@]}" ':: go / tool' \
build \
-v \
-tags netgo \
-ldflags 'all=-s -extld=gcc -extldflags=-static' \
-gcflags 'all=-l=4' \
-o "${_outputs}/binaries/release/kawipiko-server-dummy" \
-- ./cmd/server-dummy.go \
#
exec env -i -- "${_outputs}/binaries/release/kawipiko-server-dummy" "${@}"
!!

View file

@ -0,0 +1,32 @@
package main
import "runtime"
import "runtime/debug"
import "github.com/valyala/fasthttp"
import "github.com/valyala/fasthttp/reuseport"
func main () () {
runtime.GOMAXPROCS (2)
debug.SetGCPercent (50)
debug.SetMaxThreads (128)
debug.SetMaxStack (16 * 1024)
_data := []byte ("hello world!\n")
_listener, _error := reuseport.Listen ("tcp4", "127.9.185.194:8080")
if _error != nil { panic (_error) }
_error = fasthttp.Serve (
_listener,
func (_context *fasthttp.RequestCtx) () {
_context.Response.SetBodyRaw (_data)
})
if _error != nil { panic (_error) }
}