2017-07-05 02:34:06 +00:00
|
|
|
package benchmarks
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/animenotifier/arn"
|
|
|
|
)
|
|
|
|
|
2017-07-05 11:46:20 +00:00
|
|
|
func BenchmarkDBAnimeListGetMap(b *testing.B) {
|
2017-07-05 11:08:27 +00:00
|
|
|
user, _ := arn.GetUser("4J6qpK1ve")
|
|
|
|
|
2017-07-05 02:34:06 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
2017-10-01 22:01:01 +00:00
|
|
|
animeList, _ := arn.GetAnimeList(user.ID)
|
2017-07-05 11:08:27 +00:00
|
|
|
noop(animeList)
|
2017-07-05 02:34:06 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-07-05 11:46:20 +00:00
|
|
|
func BenchmarkDBAnimeListGet(b *testing.B) {
|
2017-07-05 02:34:06 +00:00
|
|
|
b.ReportAllocs()
|
|
|
|
b.ResetTimer()
|
|
|
|
|
|
|
|
b.RunParallel(func(pb *testing.PB) {
|
|
|
|
for pb.Next() {
|
2017-07-05 11:08:27 +00:00
|
|
|
list, _ := arn.DB.Get("AnimeList", "4J6qpK1ve")
|
|
|
|
animeList := list.(*arn.AnimeList)
|
|
|
|
noop(animeList)
|
2017-07-05 02:34:06 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2017-07-05 11:08:27 +00:00
|
|
|
|
|
|
|
func noop(list *arn.AnimeList) {}
|