Added benchmark

This commit is contained in:
Eduard Urbach 2017-07-05 04:34:06 +02:00
parent 0e42105049
commit 8dbc8f17cf
2 changed files with 34 additions and 0 deletions

View File

@ -30,6 +30,11 @@ func BenchmarkAnimeList(b *testing.B) {
user, _ := arn.GetUser("4J6qpK1ve")
animeList := user.AnimeList()
// Prefetch
for _, item := range animeList.Items {
item.Anime()
}
b.ReportAllocs()
b.ResetTimer()

29
benchmarks/DB_test.go Normal file
View File

@ -0,0 +1,29 @@
package benchmarks
import (
"testing"
"github.com/animenotifier/arn"
)
func BenchmarkDBGetMap(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
arn.DB.GetMap("AnimeList", "4J6qpK1ve")
}
})
}
func BenchmarkDBGet(b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
arn.DB.Get("AnimeList", "4J6qpK1ve")
}
})
}