mirror of
https://github.com/logos-messaging/logos-messaging-go-bindings.git
synced 2026-01-05 15:33:08 +00:00
add new stress test
This commit is contained in:
parent
996aed4fac
commit
55720f9918
@ -1,5 +1,5 @@
|
||||
//go:build stress
|
||||
// +build stress
|
||||
//go:build !stress
|
||||
// +build !stress
|
||||
|
||||
package waku
|
||||
|
||||
@ -230,3 +230,52 @@ func TestStoreQuery5kMessagesWithPagination(t *testing.T) {
|
||||
|
||||
Debug("[%s] Test completed successfully", t.Name())
|
||||
}
|
||||
|
||||
func TestHighThroughput10kPublish(t *testing.T) {
|
||||
|
||||
node1Cfg := DefaultWakuConfig
|
||||
node1Cfg.Relay = true
|
||||
node1, err := StartWakuNode("node1", &node1Cfg)
|
||||
require.NoError(t, err, "Failed to start node1")
|
||||
defer node1.StopAndDestroy()
|
||||
|
||||
node2Cfg := DefaultWakuConfig
|
||||
node2Cfg.Relay = true
|
||||
node2, err := StartWakuNode("node2", &node2Cfg)
|
||||
require.NoError(t, err, "Failed to start node2")
|
||||
defer node2.StopAndDestroy()
|
||||
|
||||
err = node1.ConnectPeer(node2)
|
||||
require.NoError(t, err, "Failed to connect node1 to node2")
|
||||
|
||||
var memStats runtime.MemStats
|
||||
runtime.ReadMemStats(&memStats)
|
||||
startHeapKB := memStats.HeapAlloc / 1024
|
||||
startRSSKB, err := utils.GetRSSKB()
|
||||
require.NoError(t, err, "Failed to read initial RSS")
|
||||
|
||||
Debug("Memory usage BEFORE sending => HeapAlloc: %d KB, RSS: %d KB", startHeapKB, startRSSKB)
|
||||
|
||||
totalMessages := 10000
|
||||
pubsubTopic := DefaultPubsubTopic
|
||||
|
||||
startTime := time.Now()
|
||||
for i := 0; i < totalMessages; i++ {
|
||||
message := node1.CreateMessage()
|
||||
message.Payload = []byte(fmt.Sprintf("High-throughput message #%d", i))
|
||||
|
||||
_, err := node1.RelayPublishNoCTX(pubsubTopic, message)
|
||||
require.NoError(t, err, "Failed to publish message %d", i)
|
||||
}
|
||||
duration := time.Since(startTime)
|
||||
|
||||
runtime.ReadMemStats(&memStats)
|
||||
endHeapKB := memStats.HeapAlloc / 1024
|
||||
endRSSKB, err := utils.GetRSSKB()
|
||||
require.NoError(t, err, "Failed to read final RSS")
|
||||
|
||||
Debug("Memory usage AFTER sending => HeapAlloc: %d KB, RSS: %d KB", endHeapKB, endRSSKB)
|
||||
|
||||
Debug("Published %d messages in %s", totalMessages, duration)
|
||||
Debug("Total time per message ~ %v", duration/time.Duration(totalMessages))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user