github.com/moqsien/xraycore@v1.8.5/proxy/vmess/validator_test.go (about)

     1  package vmess_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/moqsien/xraycore/common"
     7  	"github.com/moqsien/xraycore/common/protocol"
     8  	"github.com/moqsien/xraycore/common/uuid"
     9  	. "github.com/moqsien/xraycore/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  }