Removed thread benchmark
This commit is contained in:
parent
8c19f0be72
commit
2c67ddad95
27
benchmarks/Components_test.go
Normal file
27
benchmarks/Components_test.go
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package benchmarks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/animenotifier/arn"
|
||||||
|
"github.com/animenotifier/notify.moe/components"
|
||||||
|
)
|
||||||
|
|
||||||
|
func BenchmarkThread(b *testing.B) {
|
||||||
|
thread, _ := arn.GetThread("HJgS7c2K")
|
||||||
|
thread.HTML() // Pre-render markdown
|
||||||
|
|
||||||
|
replies, _ := arn.FilterPosts(func(post *arn.Post) bool {
|
||||||
|
post.HTML() // Pre-render markdown
|
||||||
|
return post.ThreadID == thread.ID
|
||||||
|
})
|
||||||
|
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.ResetTimer()
|
||||||
|
|
||||||
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
for pb.Next() {
|
||||||
|
components.Thread(thread, replies, nil)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
@ -26,30 +26,10 @@ func Get(ctx *aero.Context) string {
|
|||||||
|
|
||||||
arn.SortPostsLatestLast(replies)
|
arn.SortPostsLatestLast(replies)
|
||||||
|
|
||||||
for i := 0; i < 7; i++ {
|
// Benchmark
|
||||||
replies = append(replies, replies...)
|
// for i := 0; i < 7; i++ {
|
||||||
}
|
// replies = append(replies, replies...)
|
||||||
|
// }
|
||||||
println(len(replies))
|
|
||||||
|
|
||||||
// Pre-render markdown
|
|
||||||
// flow.Parallel(func() {
|
|
||||||
// for _, reply := range replies[0:256] {
|
|
||||||
// reply.HTML()
|
|
||||||
// }
|
|
||||||
// }, func() {
|
|
||||||
// for _, reply := range replies[256:512] {
|
|
||||||
// reply.HTML()
|
|
||||||
// }
|
|
||||||
// }, func() {
|
|
||||||
// for _, reply := range replies[512:768] {
|
|
||||||
// reply.HTML()
|
|
||||||
// }
|
|
||||||
// }, func() {
|
|
||||||
// for _, reply := range replies[768:1024] {
|
|
||||||
// reply.HTML()
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
|
|
||||||
if filterErr != nil {
|
if filterErr != nil {
|
||||||
return ctx.Error(500, "Error fetching thread replies", err)
|
return ctx.Error(500, "Error fetching thread replies", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user