|
@@ -11,17 +11,17 @@ import (
|
|
|
. "v2ray.com/core/proxy/vmess"
|
|
. "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) {
|
|
func TestUserValidator(t *testing.T) {
|
|
|
hasher := protocol.DefaultIDHash
|
|
hasher := protocol.DefaultIDHash
|
|
|
v := NewTimedUserValidator(hasher)
|
|
v := NewTimedUserValidator(hasher)
|
|
|
defer common.Close(v)
|
|
defer common.Close(v)
|
|
|
|
|
|
|
|
- toAccount := func(a *Account) protocol.Account {
|
|
|
|
|
- account, err := a.AsAccount()
|
|
|
|
|
- common.Must(err)
|
|
|
|
|
- return account
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
id := uuid.New()
|
|
id := uuid.New()
|
|
|
user := &protocol.MemoryUser{
|
|
user := &protocol.MemoryUser{
|
|
|
Email: "test",
|
|
Email: "test",
|
|
@@ -88,3 +88,23 @@ func TestUserValidator(t *testing.T) {
|
|
|
t.Error("remove user twice")
|
|
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)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|