From 7ad3a9969fa9fcd7d2219a445d7bb17e28d04cd4 Mon Sep 17 00:00:00 2001 From: Urko Date: Mon, 10 Apr 2023 19:49:43 +0200 Subject: [PATCH] feat: add readme --- Makefile | 13 ++++++++++-- README.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 68 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index b87486e..48fd50a 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ pprof: pprof_url:# top 40 -cum go tool pprof -alloc_space http://localhost:5000/debug/pprof/allocs benchmark_server: - go test -gcflags "-m -m" -run none -bench . -benchtime 30s -benchmem -memprofile profile.out ./benchmark + go test -gcflags "-m -m" -run none -bench . -benchtime 30s -benchmem -memprofile profile.out ./benchmark benchmark_etl: go test -gcflags "-m -m" -run none -bench . -benchtime 15s -benchmem -memprofile profile.out ./internal/etl/ > t.out trace_etl: build_etl# go tool trace t.out @@ -28,8 +28,17 @@ trace_etl: build_etl# go tool trace t.out time ./etl -trace > t.out build_etl: env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -v -o etl ./cmd/etl/main.go +run_etl: build_etl + ./etl build_server: env GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -o server ./cmd/server/main.go run_server: build_server ./server - +benchmark_go_1000req: + go test -run TestGoRequests ./benchmark +benchmark_go_1000req_15s: + go test -run TestGoRequestsPerSecondFor15s ./benchmark +benchmark_nest_1000req: + go test -run TestNestRequests ./benchmark +benchmark_nest_1000req_15s: + go test -run TestNestRequestsPerSecondFor15s ./benchmark \ No newline at end of file diff --git a/README.md b/README.md index ea27d10..a2a55ca 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,63 @@ +## Requirements +run `docker-compose --env-file ./.env up` to init your container +## Tests +### ETL +To see results you only have to run +```bash +make run_etl +``` + +### http server +To see results you only have to run +```bash +make run_etl +``` + ## Benchmark -### go benchmark -Start your server -`go run cmd/server/main.go` +### http comparision +#### Start your go http server +```bash +go run cmd/server/main.go +``` +#### Start your nest server +```bash +cd ~/nest-project-path +``` +```bash +npm start +``` -Run your tests -`go test -race -v --bench ./. --benchmem ./benchmark ` +Then run benchmark +```bash +make benchmark_server +``` +### other tests +To test different tests done on http server response you can do this way: +First start your http server +```bash +make run_server +``` +Then play running different tests: + +**IMPORTANT** Please do mantain your machine without extra running processes + +```bash +make benchmark_go_1000req_15s +``` +then try + +```bash +make benchmark_go_1000req +``` + +Now try nest server, remember to first [startup your nest](#start-your-nest-server) +```bash +make benchmark_nest_1000req_15s +``` +```bash +make benchmark_nest_1000req +``` \ No newline at end of file