summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-11 04:36:59 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-11 04:54:53 -0400
commit00eaadc6ed2859ccf3683486667fe20374893421 (patch)
treed0218e7d36e295a031c1a5334da999f246e5d97b
parent367e44f691dbd5647a7d6ae7bdbd7857b35d92a8 (diff)
downloadgetwtxt-00eaadc6ed2859ccf3683486667fe20374893421.tar.gz
updated cache benchmarks
-rw-r--r--svc/cache_test.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/svc/cache_test.go b/svc/cache_test.go
index 2177917..8b9b06d 100644
--- a/svc/cache_test.go
+++ b/svc/cache_test.go
@@ -2,6 +2,8 @@ package svc // import "github.com/getwtxt/getwtxt/svc"
 
 import (
 	"testing"
+
+	"github.com/getwtxt/registry"
 )
 
 func Benchmark_cacheUpdate(b *testing.B) {
@@ -11,6 +13,22 @@ func Benchmark_cacheUpdate(b *testing.B) {
 
 	for i := 0; i < b.N; i++ {
 		cacheUpdate()
+
+		// make sure it's pulling new statuses
+		// half the time so we get a good idea
+		// of its performance in both cases.
+		if i > 2 && i%2 == 0 {
+			b.StopTimer()
+			twtxtCache.Mu.Lock()
+			user := twtxtCache.Users["https://gbmor.dev/twtxt.txt"]
+			user.Mu.Lock()
+			user.Status = registry.NewTimeMap()
+			user.RLen = "0"
+			twtxtCache.Users["https://gbmor.dev/twtxt.txt"] = user
+			user.Mu.Unlock()
+			twtxtCache.Mu.Unlock()
+			b.StartTimer()
+		}
 	}
 }