stacktrace_benchmark_test.go 783 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package xruntime
  2. import (
  3. "fmt"
  4. "testing"
  5. "github.com/ydb-platform/ydb/library/go/test/testhelpers"
  6. )
  7. func BenchmarkNew(b *testing.B) {
  8. inputs := []struct {
  9. Name string
  10. Func func(skip int) *StackTrace
  11. }{
  12. {
  13. Name: "Frame",
  14. Func: NewFrame,
  15. },
  16. {
  17. Name: "StackTrace16",
  18. Func: NewStackTrace16,
  19. },
  20. {
  21. Name: "StackTrace32",
  22. Func: NewStackTrace32,
  23. },
  24. {
  25. Name: "StackTrace64",
  26. Func: NewStackTrace64,
  27. },
  28. {
  29. Name: "StackTrace128",
  30. Func: NewStackTrace128,
  31. },
  32. }
  33. for _, depth := range []int{1, 16, 32, 64, 128, 256} {
  34. for _, input := range inputs {
  35. b.Run(fmt.Sprintf("Depth%d_%s", depth, input.Name), func(b *testing.B) {
  36. for i := 0; i < b.N; i++ {
  37. testhelpers.Recurse(depth, func() { input.Func(0) })
  38. }
  39. })
  40. }
  41. }
  42. }