Skip to content

Benchmark Report

Iván Corrales Solera edited this page Dec 15, 2018 · 5 revisions

Benchmark

The below tables show the result for running the implemented bechmark tests.

stream.At

Asking for element in a random position

Test Identifier Stream Len Speed
BenchmarkAtString10-4 10 160 ns/op
BenchmarkAtString100-4 100 229 ns/op
BenchmarkAtString1000-4 1000 211 ns/op
BenchmarkAtString5000-4 5000 156 ns/op

stream.First

Asking for element in the first position

Test Identifier Stream Len Speed
BenchmarkFirstString10-4 10 235 ns/op
BenchmarkFirstString100-4 100 191 ns/op
BenchmarkFirstString1000-4 1000 370 ns/op
BenchmarkFirstString5000-4 5000 259 ns/op

stream.Last

Asking for element in the last position

Test Identifier Stream Len Speed
BenchmarkLastString10-4 10 200 ns/op
BenchmarkLastString100-4 100 204 ns/op
BenchmarkLastString1000-4 1000 214 ns/op
BenchmarkLastString5000-4 5000 190 ns/op

stream.Add

Adding a new element in a stream of strings

Test Identifier Stream Len Speed
BenchmarkAddString10-4 10 718 ns/op
BenchmarkAddString100-4 100 1276 ns/op
BenchmarkAddString1000-4 1000 7561 ns/op
BenchmarkAddString5000-4 5000 44036 ns/op

stream.Drop

Remove an element (that exists) from a stream of strings

Test Identifier Stream Len Speed
BenchmarkAddString10-4 10 686 ns/op
BenchmarkAddString100-4 100 850 ns/op
BenchmarkAddString1000-4 1000 2086 ns/op
BenchmarkAddString5000-4 5000 10275 ns/op

Remove an element (that does not exist) from a stream of strings

Test Identifier Stream Len Speed
BenchmarkDropString10UnExistingElement-4 10 584 ns/op
BenchmarkDropString100UnExistingElement-4 100 711 ns/op
BenchmarkDropString1000UnExistingElement-4 1000 1393 ns/op
BenchmarkDropString5000UnExistingElement-4 5000 3763 ns/op

stream.Map

Converting a stream of strings in a new stream of strings with uppercase

Test Identifier Stream Len Speed
BenchmarkMapString10ToUpper-4 10 1366 ns/op
BenchmarkMapString100ToUpper-4 10 7496 ns/op
BenchmarkMapString1000ToUpper-4 10 79248 ns/op
BenchmarkMapString5000ToUpper-4 10 507272 ns/op

Converting a stream of strings in a new stream of int with the len of all the elements

Test Identifier Stream Len Speed
BenchmarkReduceInt10Sum-4 10 324 ns/op
BenchmarkReduceInt100Sum-4 100 629 ns/op
BenchmarkReduceInt1000Sum-4 1000 3782 ns/op
BenchmarkReduceInt5000Sum-4 5000 9533 ns/op

|

stream.Filter

Removing from the stream those elements that they're not even

Test Identifier Stream Len Speed
BenchmarkFilterNumbers10LenIsEven-4 10 850 ns/op
BenchmarkFilterNumbers100LenIsEven-4 100 1785 ns/op
BenchmarkFilterNumbers1000LenIsEven-4 1000 17190 ns/op
BenchmarkFilterNumbers5000LenIsEven-4 5000 26437 ns/op

stream.Reduce

Sum the len of all the string elements in a tream

Test Identifier Stream Len Speed
BenchmarkReduceString10SumLen-4 10 355 ns/op
BenchmarkReduceString100SumLen-4 100 723 ns/op
BenchmarkReduceString1000SumLen-4 1000 4254 ns/op
BenchmarkReduceString5000SumLen-4 5000 21286 ns/op

Sum all the elments in a stream of ints

Test Identifier Stream Len Speed
BenchmarkReduceInt10Sum-4 10 324 ns/op
BenchmarkReduceInt100Sum-4 199 629 ns/op
BenchmarkReduceInt1000Sum-4 1999 3782 ns/op
BenchmarkReduceInt5000Sum-4 5000 9533 ns/op

stream.ForEach

Iterating over a stream of int and printing the value

Test Identifier Stream Len Speed
BenchmarkForEachNumbers10Print-4 10 445 ns/op
BenchmarkForEachNumbers100Print-4 100 647 ns/op
BenchmarkForEachNumbers1000Print-4 1000 2980 ns/op
BenchmarkForEachNumbers5000Print-4 5000 7260 ns/op

stream.RemoveDuplicates

Removing duplicated elements in a stream of strings

Test Identifier Stream Len Speed
BenchmarkDuplicatedString10-4 10 4695 ns/op
BenchmarkDuplicatedString10-4 100 39628 ns/op
BenchmarkDuplicatedString10-4 1000 413261 ns/op
BenchmarkDuplicatedString10-4 5000 2436386 ns/op

stream.Count

Counting the number of elements in a stream o strings

Test Identifier Stream Len Speed
BenchmarkCountString10-4 10 101 ns/op
BenchmarkCountString10-4 100 98.6 ns/op
BenchmarkCountString10-4 1000 108 ns/op
BenchmarkCountString10-4 5000 96.5 ns/op

stream.Contains

The searched element is in the first position of the stream of strings

Test Identifier Stream Len Speed
BenchmarkContainsString10FirstElement-4 10 284 ns/op
BenchmarkContainsString100FirstElement-4 100 331 ns/op
BenchmarkContainsString1000FirstElement-4 1000 337 ns/op
BenchmarkContainsString5000FirstElement-4 5000 346 ns/op

The searched element is in the last position of the stream of strings

Test Identifier Stream Len Speed
BenchmarkContainsString10LastElement-4 10 327 ns/op
BenchmarkContainsString100LastElement-4 100 347 ns/op
BenchmarkContainsString1000LastElement-4 1000 1060 ns/op
BenchmarkContainsString5000LastElement-4 5000 4930 ns/op

The searched element doesn't exist in the stream of strings

Test Identifier Stream Len Speed
BenchmarkContainsString10NotFound-4 10 246 ns/op
BenchmarkContainsString100NotFound-4 100 515 ns/op
BenchmarkContainsString1000NotFound-4 1000 1650 ns/op
BenchmarkContainsString5000NotFound-4 5000 8905 ns/op

stream.Reverse

Reversing sequence of elements in a stream of strings

Test Identifier Stream Len Speed
BenchmarkReverseString10-4 10 477 ns/op
BenchmarkReverseString100-4 100 1218 ns/op
BenchmarkReverseString1000-4 1000 7505 ns/op
BenchmarkReverseString5000-4 5000 37553 ns/op

stream.Take

Taking the elements between positions 1 and len-1

Test Identifier Stream Len Speed
BenchmarkTakeNumbers1000Between1and9-4 10 326 ns/op
BenchmarkTakeNumbers1000Between1and99-4 100 323 ns/op
BenchmarkTakeNumbers1000Between1and999-4 1000 335 ns/op
BenchmarkTakeNumbers2500etween1and2499-4 5000 321 ns/op

stream.LastIndexOf

LastIndexOf the first element in the stream

Test Identifier Stream Len Speed
BenchmarkLastIndexOfString10FirstElement-4 10 274 ns/op
BenchmarkLastIndexOfString100FirstElement-4 100 325 ns/op
BenchmarkLastIndexOfString1000FirstElement-4 1000 582 ns/op
BenchmarkLastIndexOfString5000FirstElement-4 5000 3832 ns/op

LastIndexOf the last element in the stream

Test Identifier Stream Len Speed
BenchmarkLastIndexOfString10LastElement-4 10 275 ns/op
BenchmarkLastIndexOfString100LastElement-4 100 279 ns/op
BenchmarkLastIndexOfString1000LastElement-4 1000 280 ns/op
BenchmarkLastIndexOfString5000LastElement-4 5000 279 ns/op

LastIndexOf a non found element

Test Identifier Stream Len Speed
BenchmarkLastIndexOfString10NotFound-4 10 243 ns/op
BenchmarkLastIndexOfString100NotFound-4 100 361 ns/op
BenchmarkLastIndexOfString1000NotFound-4 1000 1433 ns/op
BenchmarkLastIndexOfString5000NotFound-4 5000 7267 ns/op

stream.Set

Repleace element in position 0

Test Identifier Stream Len Speed
BenchmarkSetString10-4 10 771 ns/op
BenchmarkSetString100-4 100 1451 ns/op
BenchmarkSetString1000-4 1000 6717 ns/op
BenchmarkSetString5000-4 5000 32890 ns/op

stream.IndexOf

IndexOf the first element in the stream

Test Identifier Stream Len Speed
BenchmarkIndexOfString10FirstElement-4 10 275 ns/op
BenchmarkIndexOfString100FirstElement-4 100 277 ns/op
BenchmarkIndexOfString1000FirstElement-4 1000 280 ns/op
BenchmarkIndexOfString5000FirstElement-4 5000 276 ns/op

IndexOf the last element in the stream

Test Identifier Stream Len Speed
BenchmarkIndexOfString10LastElement-4 10 273 ns/op
BenchmarkIndexOfString100LastElement-4 100 327 ns/op
BenchmarkIndexOfString1000LastElement-4 1000 764 ns/op
BenchmarkIndexOfString5000LastElement-4 5000 3687 ns/op

IndexOf a non found element

Test Identifier Stream Len Speed
BenchmarkIndexOfString10NotFound-4 10 266 ns/op
BenchmarkIndexOfString100NotFound-4 100 337 ns/op
BenchmarkIndexOfString1000NotFound-4 1000 1248 ns/op
BenchmarkIndexOfString5000NotFound-4 5000 7288 ns/op