From da7c548d172b199f407356a44ac6c89917c9c6f4 Mon Sep 17 00:00:00 2001 From: Yury Smolski <140245+ysmolski@users.noreply.github.com> Date: Mon, 7 Jul 2025 19:29:06 +0300 Subject: [PATCH] fix: use int in reflect's benchmark This fixes the failing Benchmark in the netpoll lib. --- v2/pkg/netpoll/fd_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/pkg/netpoll/fd_test.go b/v2/pkg/netpoll/fd_test.go index ad4c08d019..beb0a94176 100644 --- a/v2/pkg/netpoll/fd_test.go +++ b/v2/pkg/netpoll/fd_test.go @@ -8,12 +8,12 @@ import ( "testing" ) -func reflectSocketFDAsUint(conn net.Conn) uint64 { +func reflectSocketFDAsInt(conn net.Conn) int64 { tcpConn := reflect.Indirect(reflect.ValueOf(conn)).FieldByName("conn") fdVal := tcpConn.FieldByName("fd") pfdVal := reflect.Indirect(fdVal).FieldByName("pfd") - return pfdVal.FieldByName("Sysfd").Uint() + return pfdVal.FieldByName("Sysfd").Int() } func rawSocketFD(conn net.Conn) uint64 { @@ -33,12 +33,12 @@ func rawSocketFD(conn net.Conn) uint64 { func BenchmarkSocketFdReflect(b *testing.B) { var con, _ = net.Dial(`udp`, "8.8.8.8:53") - fd := uint64(0) + fd := int64(0) b.ResetTimer() b.ReportAllocs() for i := 0; i < b.N; i++ { - fd = reflectSocketFDAsUint(con) + fd = reflectSocketFDAsInt(con) } runtime.KeepAlive(fd) }