@@ -239,11 +239,12 @@ func BenchmarkTopicPut(b *testing.B) {
239
239
_ , _ , nsqd := mustStartNSQD (opts )
240
240
defer os .RemoveAll (opts .DataPath )
241
241
defer nsqd .Exit ()
242
+ gf := & test.GUIDFactory {}
242
243
b .StartTimer ()
243
244
244
245
for i := 0 ; i <= b .N ; i ++ {
245
246
topic := nsqd .GetOrCreateTopic (topicName )
246
- msg := NewMessage (topic . GenerateID (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
247
+ msg := NewMessage (guid ( gf . NextMessageID ()). Hex (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
247
248
topic .PutMessage (msg )
248
249
}
249
250
}
@@ -260,11 +261,12 @@ func BenchmarkTopicToChannelPut(b *testing.B) {
260
261
defer os .RemoveAll (opts .DataPath )
261
262
defer nsqd .Exit ()
262
263
channel := nsqd .GetOrCreateTopic (topicName ).GetOrCreateChannel (channelName )
264
+ gf := & test.GUIDFactory {}
263
265
b .StartTimer ()
264
266
265
267
for i := 0 ; i <= b .N ; i ++ {
266
268
topic := nsqd .GetOrCreateTopic (topicName )
267
- msg := NewMessage (topic . GenerateID (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
269
+ msg := NewMessage (guid ( gf . NextMessageID ()). Hex (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
268
270
topic .PutMessage (msg )
269
271
}
270
272
@@ -290,6 +292,7 @@ func BenchmarkTopicMessagePump(b *testing.B) {
290
292
topic := nsqd .GetOrCreateTopic (topicName )
291
293
ch := topic .GetOrCreateChannel ("ch" )
292
294
ctx , cancel := context .WithCancel (context .Background ())
295
+ gf := & test.GUIDFactory {}
293
296
294
297
var wg sync.WaitGroup
295
298
for i := 0 ; i < runtime .GOMAXPROCS (0 ); i ++ {
@@ -308,7 +311,7 @@ func BenchmarkTopicMessagePump(b *testing.B) {
308
311
309
312
b .StartTimer ()
310
313
for i := 0 ; i <= b .N ; i ++ {
311
- msg := NewMessage (topic . GenerateID (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
314
+ msg := NewMessage (guid ( gf . NextMessageID ()). Hex (), []byte ("aaaaaaaaaaaaaaaaaaaaaaaaaaa" ))
312
315
topic .PutMessage (msg )
313
316
}
314
317
cancel ()
0 commit comments