From 2561a007b8d8999a4750046d0cfb3b1ad5af50ac Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期二, 09 四月 2024 15:29:32 +0800 Subject: [PATCH] test for perf --- api/bhsgo/bhome_node.go | 68 ++++++++++++++-------------------- 1 files changed, 28 insertions(+), 40 deletions(-) diff --git a/api/bhsgo/bhome_node.go b/api/bhsgo/bhome_node.go index 1b4564f..11a3005 100644 --- a/api/bhsgo/bhome_node.go +++ b/api/bhsgo/bhome_node.go @@ -40,8 +40,8 @@ func Register(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := proc.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHRegister(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -54,8 +54,8 @@ func RegisterTopics(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := topics.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHRegisterTopics(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -68,8 +68,8 @@ func Subscribe(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := topics.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHSubscribeTopics(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -83,8 +83,8 @@ func SubscribeNet(topics *bh.MsgTopicList, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := topics.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHSubscribeNetTopics(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -97,8 +97,8 @@ func Heartbeat(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := proc.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHHeartbeat(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -115,8 +115,8 @@ func Unregister(proc *bh.ProcInfo, reply *bh.MsgCommonReply, timeout_ms int) bool { data, _ := proc.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHUnregister(getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 defer C.BHFree(creply, creply_len) @@ -130,8 +130,8 @@ func QueryTopicAddress(dest_addr *bh.BHAddress, topic *bh.MsgQueryTopic, reply *bh.MsgQueryTopicReply, timeout_ms int) bool { dest, _ := dest_addr.Marshal() data, _ := topic.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHQueryTopicAddress(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 if r { @@ -146,8 +146,8 @@ func QueryProcs(dest_addr *bh.BHAddress, topic *bh.MsgQueryProc, reply *bh.MsgQueryProcReply, timeout_ms int) bool { dest, _ := dest_addr.Marshal() data, _ := topic.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHQueryProcs(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &creply, &creply_len, C.int(timeout_ms)) > 0 if r { @@ -165,11 +165,8 @@ } func ReadSub(proc_id *string, pub *bh.MsgPublish, timeout_ms int) bool { - cpid := unsafe.Pointer(nil) - cpid_len := C.int(0) - - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var cpid, creply unsafe.Pointer + var cpid_len, creply_len C.int r := C.BHReadSub(&cpid, &cpid_len, &creply, &creply_len, C.int(timeout_ms)) > 0 if r { @@ -185,8 +182,8 @@ func AsyncRequest(dest_addr *bh.BHAddress, req *bh.MsgRequestTopic, msg_id *[]byte) bool { dest, _ := dest_addr.Marshal() data, _ := req.Marshal() - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHAsyncRequest(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &creply, &creply_len) > 0 defer C.BHFree(creply, creply_len) @@ -199,11 +196,8 @@ func Request(dest_addr *bh.BHAddress, req *bh.MsgRequestTopic, proc_id *string, reply *bh.MsgRequestTopicReply, timeout_ms int) bool { dest, _ := dest_addr.Marshal() data, _ := req.Marshal() - cpid := unsafe.Pointer(nil) - cpid_len := C.int(0) - - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var cpid, creply unsafe.Pointer + var cpid_len, creply_len C.int r := C.BHRequest(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &cpid, &cpid_len, &creply, &creply_len, C.int(timeout_ms)) > 0 if r { @@ -218,11 +212,8 @@ } func ReadRequest(proc_id *string, req *bh.MsgRequestTopic, psrc *unsafe.Pointer, timeout_ms int) bool { - cpid := unsafe.Pointer(nil) - cpid_len := C.int(0) - - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var cpid, creply unsafe.Pointer + var cpid_len, creply_len C.int r := C.BHReadRequest(&cpid, &cpid_len, &creply, &creply_len, psrc, C.int(timeout_ms)) > 0 if r { @@ -244,8 +235,8 @@ } func GetLastError() (int, string) { - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var creply unsafe.Pointer + var creply_len C.int r := C.BHGetLastError(&creply, &creply_len) defer C.BHFree(creply, creply_len) @@ -261,11 +252,8 @@ // /////////////////////////////////////////////////// func Request2(dest_addr *bh.BHAddress, data []byte, proc_id *string, replyPtr *unsafe.Pointer, replyLen *int, timeout_ms int) bool { dest, _ := dest_addr.Marshal() - cpid := unsafe.Pointer(nil) - cpid_len := C.int(0) - - creply := unsafe.Pointer(nil) - creply_len := C.int(0) + var cpid, creply unsafe.Pointer + var cpid_len, creply_len C.int r := C.BHRequest(getPtr(&dest), C.int(len(dest)), getPtr(&data), C.int(len(data)), &cpid, &cpid_len, &creply, &creply_len, C.int(timeout_ms)) > 0 if r { -- Gitblit v1.8.0