summary refs log blame commit diff stats
path: root/svc/cache_test.go
blob: 2177917ce0bf1c3864ef92494942978756d345eb (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                      

        
                 

 
                                          
                      
                      


                                  
                             

         






                                         








                                                                    

         
package svc // import "github.com/getwtxt/getwtxt/svc"

import (
	"testing"
)

func Benchmark_cacheUpdate(b *testing.B) {
	initTestConf()
	mockRegistry()
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		cacheUpdate()
	}
}

func Benchmark_pingAssets(b *testing.B) {
	initTestConf()
	b.ResetTimer()

	for i := 0; i < b.N; i++ {
		pingAssets()

		// We'll only have to reload the cache occasionally,
		// so only start with an empty staticCache 25% of
		// the time.
		if float64(i) > (float64(b.N) * .75) {
			b.StopTimer()
			staticCache = &staticAssets{}
			b.StartTimer()
		}
	}
}