fx_test.go 333 B

12345678910111213141516171819202122232425
  1. package main
  2. import (
  3. "testing"
  4. "github.com/tal-tech/go-zero/core/fx"
  5. )
  6. func BenchmarkFx(b *testing.B) {
  7. type Mixed struct {
  8. Name string
  9. Age int
  10. Gender int
  11. }
  12. for i := 0; i < b.N; i++ {
  13. var mx Mixed
  14. fx.Parallel(func() {
  15. mx.Name = "hello"
  16. }, func() {
  17. mx.Age = 20
  18. }, func() {
  19. mx.Gender = 1
  20. })
  21. }
  22. }