From 9f3e98d84ae0755196be26ae099772039420c539 Mon Sep 17 00:00:00 2001 From: Ugur SEN Date: Wed, 18 Jan 2023 03:01:29 +0300 Subject: [PATCH] Benchmark bug fixed(interface conversion). go test -run=NO_TEST -bench . -benchmem -benchtime 1s This command gives an error (panic: interface conversion: interface {} is int, not priorityqueue.Element) and to fix this enqueue(n)s changed to enqueu(Element{})s. --- queues/priorityqueue/priorityqueue_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/queues/priorityqueue/priorityqueue_test.go b/queues/priorityqueue/priorityqueue_test.go index 1036fdb..6c0db89 100644 --- a/queues/priorityqueue/priorityqueue_test.go +++ b/queues/priorityqueue/priorityqueue_test.go @@ -476,7 +476,7 @@ func TestBTreeString(t *testing.T) { func benchmarkEnqueue(b *testing.B, queue *Queue, size int) { for i := 0; i < b.N; i++ { for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } } } @@ -494,7 +494,7 @@ func BenchmarkBinaryQueueDequeue100(b *testing.B) { size := 100 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkDequeue(b, queue, size) @@ -505,7 +505,7 @@ func BenchmarkBinaryQueueDequeue1000(b *testing.B) { size := 1000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkDequeue(b, queue, size) @@ -516,7 +516,7 @@ func BenchmarkBinaryQueueDequeue10000(b *testing.B) { size := 10000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkDequeue(b, queue, size) @@ -527,7 +527,7 @@ func BenchmarkBinaryQueueDequeue100000(b *testing.B) { size := 100000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkDequeue(b, queue, size) @@ -546,7 +546,7 @@ func BenchmarkBinaryQueueEnqueue1000(b *testing.B) { size := 1000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkEnqueue(b, queue, size) @@ -557,7 +557,7 @@ func BenchmarkBinaryQueueEnqueue10000(b *testing.B) { size := 10000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkEnqueue(b, queue, size) @@ -568,7 +568,7 @@ func BenchmarkBinaryQueueEnqueue100000(b *testing.B) { size := 100000 queue := NewWith(byPriority) for n := 0; n < size; n++ { - queue.Enqueue(n) + queue.Enqueue(Element{}) } b.StartTimer() benchmarkEnqueue(b, queue, size)