optimizing the array stack to shrink array by factor of 1.5, now array stack is faster than linked list stack

This commit is contained in:
Emir Pasic
2015-03-05 21:10:37 +01:00
parent 50875b13a8
commit 09f75253fe
4 changed files with 27 additions and 18 deletions
+2 -2
View File
@@ -72,8 +72,8 @@ func TestArrayStack(t *testing.T) {
}
func BenchmarkArrayStack(b *testing.B) {
// Slow in comparison to the LinkedListStack
// BenchmarkArrayStack 50 31760994 ns/op 8540863 B/op 2010 allocs/op
// Faster in comparison to the LinkedListStack
// BenchmarkArrayStack 5000 325010 ns/op 71648 B/op 1009 allocs/op
// BenchmarkLinkedListStack 5000 390812 ns/op 40016 B/op 2001 allocs/op
for i := 0; i < b.N; i++ {
stack := New()