github.com/go-ego/cedar@v0.10.2/cedar_bm_test.go (about) 1 package cedar 2 3 import ( 4 "testing" 5 6 "github.com/vcaesar/tt" 7 ) 8 9 func init() { 10 loadTestData() 11 } 12 13 func BenchmarkPrefixMatch(t *testing.B) { 14 fn := func() { 15 cd.PrefixMatch([]byte("abcdefg"), 0) 16 } 17 18 tt.BM(t, fn) 19 } 20 21 func BenchmarkInsert(t *testing.B) { 22 fn := func() { 23 cd.Insert([]byte("a"), 1) 24 cd.Insert([]byte("b"), 3) 25 cd.Insert([]byte("d"), 6) 26 } 27 28 tt.BM(t, fn) 29 } 30 31 func BenchmarkJump(t *testing.B) { 32 fn := func() { 33 cd.Jump([]byte("a"), 1) 34 } 35 36 tt.BM(t, fn) 37 } 38 39 func BenchmarkKey(t *testing.B) { 40 fn := func() { 41 cd.Key(1) 42 } 43 44 tt.BM(t, fn) 45 } 46 47 func BenchmarkValue(t *testing.B) { 48 fn := func() { 49 cd.Value(1) 50 } 51 52 tt.BM(t, fn) 53 } 54 55 func BenchmarkUpdate(t *testing.B) { 56 fn := func() { 57 cd.Update([]byte("a"), 1) 58 } 59 60 tt.BM(t, fn) 61 } 62 63 func BenchmarkDelete(t *testing.B) { 64 fn := func() { 65 cd.Delete([]byte("b")) 66 } 67 68 tt.BM(t, fn) 69 } 70 71 func BenchmarkPrefixPredict(t *testing.B) { 72 fn := func() { 73 cd.PrefixPredict([]byte("abcdefg"), 0) 74 } 75 76 tt.BM(t, fn) 77 }