MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / BenchmarkPersistentCaller_Call

Function BenchmarkPersistentCaller_Call

rpc/mux/wrapper_test.go:392–545  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

390}
391
392func BenchmarkPersistentCaller_Call(b *testing.B) {
393 log.SetLevel(log.InfoLevel)
394 utils.RemoveAll(PubKeyStorePath + "*")
395 defer utils.RemoveAll(PubKeyStorePath + "*")
396 utils.RemoveAll(publicKeyStore + "*")
397 defer utils.RemoveAll(publicKeyStore + "*")
398
399 ctx, cancel := context.WithTimeout(context.Background(), time.Second*15)
400 defer cancel()
401 err := utils.WaitForPorts(ctx, "127.0.0.1", []int{
402 2230,
403 }, time.Millisecond*200)
404
405 if err != nil {
406 log.Fatalf("wait for port ready timeout: %v", err)
407 }
408
409 _, testFile, _, _ := runtime.Caller(0)
410 confFile := filepath.Join(filepath.Dir(testFile), "../../test/node_standalone/config.yaml")
411 privateKeyPath := filepath.Join(filepath.Dir(testFile), "../../test/node_standalone/private.key")
412
413 conf.GConf, _ = conf.LoadConfig(confFile)
414 log.Debugf("GConf: %#v", conf.GConf)
415 // reset the once
416 route.Once.Reset()
417 _ = GetSessionPoolInstance().Close()
418 route.InitKMS(publicKeyStore)
419
420 addr := conf.GConf.ListenAddr // see ../test/node_standalone/config.yaml
421 masterKey := []byte("")
422 dht, err := route.NewDHTService(PubKeyStorePath, new(consistent.KMSStorage), true)
423
424 server, err := NewServerWithService(ServiceMap{route.DHTRPCName: dht})
425 if err != nil {
426 b.Fatal(err)
427 }
428
429 _ = server.InitRPCServer(addr, privateKeyPath, masterKey)
430 go server.Serve()
431
432 client := NewPersistentCaller(conf.GConf.BP.NodeID)
433 node1 := proto.NewNode()
434 _ = node1.InitNodeCryptoInfo(100 * time.Millisecond)
435 node1.Addr = "1.1.1.1:1"
436
437 reqA := &proto.PingReq{
438 Node: *node1,
439 }
440
441 respA := new(proto.PingResp)
442 err = client.Call("DHT.Ping", reqA, respA)
443 if err != nil {
444 b.Fatal(err)
445 }
446 log.Debugf("respA: %v", respA)
447
448 client = NewPersistentCaller(conf.GConf.BP.NodeID)
449 b.Run("benchmark Persistent Call Nil", func(b *testing.B) {

Callers

nothing calls this directly

Calls 15

InitNodeCryptoInfoMethod · 0.95
CallMethod · 0.95
CloseMethod · 0.95
CallNodeMethod · 0.95
SetLevelFunction · 0.92
RemoveAllFunction · 0.92
WaitForPortsFunction · 0.92
FatalfFunction · 0.92
LoadConfigFunction · 0.92
DebugfFunction · 0.92
InitKMSFunction · 0.92
NewDHTServiceFunction · 0.92

Tested by

no test coverage detected