From 2c67ddad95cd4ecc8592bba4759dee76721a6fd2 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 26 Jun 2017 16:23:38 +0200 Subject: [PATCH] Removed thread benchmark --- benchmarks/Components_test.go | 27 +++++++++++++++++++++++++++ pages/threads/threads.go | 28 ++++------------------------ 2 files changed, 31 insertions(+), 24 deletions(-) create mode 100644 benchmarks/Components_test.go diff --git a/benchmarks/Components_test.go b/benchmarks/Components_test.go new file mode 100644 index 00000000..ef68455e --- /dev/null +++ b/benchmarks/Components_test.go @@ -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) + } + }) +} diff --git a/pages/threads/threads.go b/pages/threads/threads.go index 1d735586..92d96248 100644 --- a/pages/threads/threads.go +++ b/pages/threads/threads.go @@ -26,30 +26,10 @@ func Get(ctx *aero.Context) string { arn.SortPostsLatestLast(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() - // } - // }) + // Benchmark + // for i := 0; i < 7; i++ { + // replies = append(replies, replies...) + // } if filterErr != nil { return ctx.Error(500, "Error fetching thread replies", err)