Skip to content

Commit

Permalink
benchmark (#53)
Browse files Browse the repository at this point in the history
* libraries parsing flags is bad since its invisible

* parseString wasn't adding extracted templates to the root template

* need this log only for debugging

* if session id empty then generate one

* remove logging

* fix sending on close channel panic

* add test and benchmark for controller

* redis pubsub tests and benchmark

* remove test file
  • Loading branch information
adnaan authored Feb 29, 2024
1 parent 2afea35 commit dd9b3a2
Show file tree
Hide file tree
Showing 13 changed files with 1,016 additions and 191 deletions.
19 changes: 3 additions & 16 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package fir

import (
"embed"
"flag"
"fmt"
"html/template"
"net/http"
Expand All @@ -16,7 +15,6 @@ import (
"github.com/gorilla/securecookie"
"github.com/gorilla/websocket"
"github.com/lithammer/shortuuid/v4"
"github.com/livefir/fir/internal/logger"
"github.com/livefir/fir/pubsub"
servertiming "github.com/mitchellh/go-server-timing"
"github.com/patrickmn/go-cache"
Expand Down Expand Up @@ -195,9 +193,9 @@ func NewController(name string, options ...ControllerOption) Controller {
o := &opt{
websocketUpgrader: websocket.Upgrader{
EnableCompression: true,
ReadBufferSize: 256,
WriteBufferSize: 256,
WriteBufferPool: &sync.Pool{},
// ReadBufferSize: 256,
// WriteBufferSize: 256,
// WriteBufferPool: &sync.Pool{},
},
watchExts: defaultWatchExtensions,
pubsub: pubsub.NewInmem(),
Expand All @@ -216,15 +214,6 @@ func NewController(name string, options ...ControllerOption) Controller {
option(o)
}

if o.publicDir == "" {
var publicDir string
publicDirUsage := "public directory that contains the html template files."
flag.StringVar(&publicDir, "public", ".", publicDirUsage)
flag.StringVar(&publicDir, "p", ".", publicDirUsage+" (shortand)")
flag.Parse()
o.publicDir = publicDir
}

c := &controller{
opt: *o,
name: name,
Expand All @@ -244,11 +233,9 @@ func NewController(name string, options ...ControllerOption) Controller {
if c.embedfs != nil {
c.readFile = readFileFS(*c.embedfs)
c.existFile = existFileFS(*c.embedfs)
fmt.Printf("read template files embedded in the binary")
} else {
c.readFile = readFileOS
c.existFile = existFileOS
logger.Infof("read template files from disk")
}

md := markdown(c.readFile, c.existFile)
Expand Down
Loading

0 comments on commit dd9b3a2

Please sign in to comment.