Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/srndv2/src/srnd/templates_test.go
Jeff Becker 3a6cbf9de6 move srndv2 to nntpchan repo with vendored deps so that nothing breaks every again
this deprecates the github.com/majestrate/srndv2 repo
2017-04-03 10:00:38 -04:00

46 lines
1.0 KiB
Go

package srnd
import (
"log"
"os"
"testing"
)
func makeBenchmarkDB() Database {
return NewDatabase("postgres", "srnd", "/var/run/postgresql", "", "", "")
}
func BenchmarkRenderBoardPage(b *testing.B) {
db := makeBenchmarkDB()
db.CreateTables()
defer db.Close()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
wr, err := os.Create("boardpage.html")
if err == nil {
template.genBoardPage(true, true, "prefix", "test", "overchan.random", 0, wr, db, false)
} else {
log.Println("did not write", "boardpage.html", err)
}
wr.Close()
}
})
}
func BenchmarkRenderThread(b *testing.B) {
db := makeBenchmarkDB()
db.CreateTables()
defer db.Close()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
wr, err := os.Create("thread.html")
if err == nil {
template.genThread(true, true, ArticleEntry{"<c49be1451427261@nntp.nsfl.tk>", "overchan.random"}, "prefix", "frontend", wr, db, false)
} else {
log.Println("did not write", "thread.html", err)
}
wr.Close()
}
})
}