1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-09-27 22:36:12 -04:00

benchmark test for user validator

This commit is contained in:
Darien Raymond 2019-02-20 22:56:17 +01:00
parent 8d09d74224
commit 1531642768
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

View File

@ -11,17 +11,17 @@ import (
. "v2ray.com/core/proxy/vmess"
)
func toAccount(a *Account) protocol.Account {
account, err := a.AsAccount()
common.Must(err)
return account
}
func TestUserValidator(t *testing.T) {
hasher := protocol.DefaultIDHash
v := NewTimedUserValidator(hasher)
defer common.Close(v)
toAccount := func(a *Account) protocol.Account {
account, err := a.AsAccount()
common.Must(err)
return account
}
id := uuid.New()
user := &protocol.MemoryUser{
Email: "test",
@ -88,3 +88,23 @@ func TestUserValidator(t *testing.T) {
t.Error("remove user twice")
}
}
func BenchmarkUserValidator(b *testing.B) {
for i := 0; i < b.N; i++ {
hasher := protocol.DefaultIDHash
v := NewTimedUserValidator(hasher)
for j := 0; j < 1500; j++ {
id := uuid.New()
v.Add(&protocol.MemoryUser{
Email: "test",
Account: toAccount(&Account{
Id: id.String(),
AlterId: 16,
}),
})
}
common.Close(v)
}
}