queue_test.go 655 B

1234567891011121314151617181920212223242526
  1. package queue
  2. import "testing"
  3. // General warning: Go's benchmark utility (go test -bench .) increases the number of
  4. // iterations until the benchmarks take a reasonable amount of time to run; memory usage
  5. // is *NOT* considered. On my machine, these benchmarks hit around ~1GB before they've had
  6. // enough, but if you have less than that available and start swapping, then all bets are off.
  7. func BenchmarkQueueSerial(b *testing.B) {
  8. q := New()
  9. for i := 0; i < b.N; i++ {
  10. q.Add(nil)
  11. }
  12. for i := 0; i < b.N; i++ {
  13. q.Remove()
  14. }
  15. }
  16. func BenchmarkQueueTickTock(b *testing.B) {
  17. q := New()
  18. for i := 0; i < b.N; i++ {
  19. q.Add(nil)
  20. q.Remove()
  21. }
  22. }