feat: reusable rule engine to prevent memory reallocation
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/pr-develop This commit looks good
This commit is contained in:
@ -3,7 +3,6 @@ package proxy_test
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/http/httputil"
|
||||
@ -24,6 +23,7 @@ import (
|
||||
redisStore "forge.cadoles.com/cadoles/bouncer/internal/store/redis"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"gitlab.com/wpetit/goweb/logger"
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"forge.cadoles.com/cadoles/bouncer/internal/setup"
|
||||
@ -39,6 +39,19 @@ func BenchmarkProxies(b *testing.B) {
|
||||
name := strings.TrimSuffix(filepath.Base(f), filepath.Ext(f))
|
||||
|
||||
b.Run(name, func(b *testing.B) {
|
||||
heap, err := os.Create(filepath.Join("testdata", "proxies", name+"_heap.prof"))
|
||||
if err != nil {
|
||||
b.Fatalf("%+v", errors.Wrapf(err, "could not create heap profile"))
|
||||
}
|
||||
|
||||
defer func() {
|
||||
defer heap.Close()
|
||||
|
||||
if err := pprof.WriteHeapProfile(heap); err != nil {
|
||||
b.Fatalf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
|
||||
conf, err := loadProxyBenchConfig(f)
|
||||
if err != nil {
|
||||
b.Fatalf("%+v", errors.Wrapf(err, "could notre load bench config"))
|
||||
@ -78,7 +91,7 @@ func BenchmarkProxies(b *testing.B) {
|
||||
|
||||
b.Logf("fetching url '%s'", rawProxyURL)
|
||||
|
||||
profile, err := os.Create(filepath.Join("testdata", "proxies", name+".prof"))
|
||||
profile, err := os.Create(filepath.Join("testdata", "proxies", name+"_cpu.prof"))
|
||||
if err != nil {
|
||||
b.Fatalf("%+v", errors.Wrapf(err, "could not create cpu profile"))
|
||||
}
|
||||
@ -86,7 +99,7 @@ func BenchmarkProxies(b *testing.B) {
|
||||
defer profile.Close()
|
||||
|
||||
if err := pprof.StartCPUProfile(profile); err != nil {
|
||||
log.Fatal(err)
|
||||
b.Fatalf("%+v", errors.WithStack(err))
|
||||
}
|
||||
|
||||
defer pprof.StopCPUProfile()
|
||||
@ -227,7 +240,12 @@ func createProxy(name string, conf *proxyBenchConfig, logf func(format string, a
|
||||
|
||||
}
|
||||
|
||||
layers, err := setup.GetLayers(context.Background(), config.NewDefault())
|
||||
appConf := config.NewDefault()
|
||||
appConf.Logger.Level = config.InterpolatedInt(logger.LevelError)
|
||||
appConf.Layers.Authn.TemplateDir = "../../layers/authn/templates"
|
||||
appConf.Layers.Queue.TemplateDir = "../../layers/queue/templates"
|
||||
|
||||
layers, err := setup.GetLayers(context.Background(), appConf)
|
||||
if err != nil {
|
||||
return nil, nil, errors.WithStack(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user