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
|
2018-10-29 04:47:13 +00:00
|
|
|
replies := thread.Posts()
|
2017-06-26 14:23:38 +00:00
|
|
|
|
2018-10-29 04:47:13 +00:00
|
|
|
for _, reply := range replies {
|
|
|
|
reply.HTML() // Pre-render markdown
|
|
|
|
}
|
2017-06-26 14:23:38 +00:00
|
|
|
|
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
2018-11-06 03:53:48 +00:00
|
|
|
components.Thread(thread, nil)
|
2017-06-26 14:23:38 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|