github.com/saintwish/kv@v1.0.4/stack/stack_test.go (about)

     1  package stack
     2  
     3  import (
     4  	"fmt"
     5  	"testing"
     6  )
     7  
     8  const maxEntries = 500
     9  
    10  func TestMoveToBack_KeyString(t *testing.T) {
    11  	m := New[int](2048)
    12  
    13  	m.Push(1337)
    14  	m.Push(1338)
    15  	m.Push(1339)
    16  	m.Push(1400)
    17  
    18  	fmt.Println(m.Stack())
    19  
    20  	m.MoveToBack(0)
    21  
    22  	fmt.Println(m.Stack())
    23  }
    24  
    25  func Benchmark_KV1_SZ2048(b *testing.B) {
    26  	m := New[int](2048)
    27  
    28  	b.ResetTimer()
    29  	for i := 0; i < b.N; i++ {
    30  		for e := 1; e <= maxEntries; e++ {
    31  			m.Push(e)
    32  		}
    33  
    34  		for e := 1; e <= maxEntries; e++ {
    35  			m.Pop()
    36  		}
    37  	}
    38  }