42 lines
770 B
Go
Raw Normal View History

2017-06-26 16:23:38 +02:00
package benchmarks
import (
"testing"
2019-06-03 18:32:43 +09:00
"github.com/animenotifier/notify.moe/arn"
2017-06-26 16:23:38 +02:00
"github.com/animenotifier/notify.moe/components"
)
2017-07-05 13:46:20 +02:00
func BenchmarkRenderThread(b *testing.B) {
2017-06-26 16:23:38 +02:00
thread, _ := arn.GetThread("HJgS7c2K")
thread.HTML() // Pre-render markdown
2018-10-29 13:47:13 +09:00
replies := thread.Posts()
2017-06-26 16:23:38 +02:00
2018-10-29 13:47:13 +09:00
for _, reply := range replies {
reply.HTML() // Pre-render markdown
}
2017-06-26 16:23:38 +02:00
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
2018-11-06 12:53:48 +09:00
components.Thread(thread, nil)
2017-06-26 16:23:38 +02:00
}
})
}
2017-07-05 04:10:19 +02:00
2017-07-05 13:46:20 +02:00
func BenchmarkRenderAnimeList(b *testing.B) {
2017-07-05 04:10:19 +02:00
user, _ := arn.GetUser("4J6qpK1ve")
animeList := user.AnimeList()
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
2018-03-17 00:28:36 +01:00
components.AnimeList(animeList.Items, -1, user, user)
2017-07-05 04:10:19 +02:00
}
})
}