42 lines
803 B
Go
Raw Normal View History

2017-06-26 14:23:38 +00:00
package benchmarks
import (
"testing"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
2017-07-05 11:46:20 +00:00
func BenchmarkRenderThread(b *testing.B) {
2017-06-26 14:23:38 +00:00
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)
}
})
}
2017-07-05 02:10:19 +00:00
2017-07-05 11:46:20 +00:00
func BenchmarkRenderAnimeList(b *testing.B) {
2017-07-05 02:10:19 +00:00
user, _ := arn.GetUser("4J6qpK1ve")
animeList := user.AnimeList()
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
2018-03-16 23:28:36 +00:00
components.AnimeList(animeList.Items, -1, user, user)
2017-07-05 02:10:19 +00:00
}
})
}