github.com/xmplusdev/xmcore@v1.8.11-0.20240412132628-5518b55526af/proxy/vmess/validator_test.go (about) 1 package vmess_test 2 3 import ( 4 "testing" 5 6 "github.com/xmplusdev/xmcore/common" 7 "github.com/xmplusdev/xmcore/common/protocol" 8 "github.com/xmplusdev/xmcore/common/uuid" 9 . "github.com/xmplusdev/xmcore/proxy/vmess" 10 ) 11 12 func toAccount(a *Account) protocol.Account { 13 account, err := a.AsAccount() 14 common.Must(err) 15 return account 16 } 17 18 func BenchmarkUserValidator(b *testing.B) { 19 for i := 0; i < b.N; i++ { 20 v := NewTimedUserValidator() 21 22 for j := 0; j < 1500; j++ { 23 id := uuid.New() 24 v.Add(&protocol.MemoryUser{ 25 Email: "test", 26 Account: toAccount(&Account{ 27 Id: id.String(), 28 }), 29 }) 30 } 31 32 common.Close(v) 33 } 34 }