validator_test.go 624 B

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