Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The case BenchmarkRange seems has some problem ? #10

Open
yandaren opened this issue Jun 27, 2021 · 1 comment
Open

The case BenchmarkRange seems has some problem ? #10

yandaren opened this issue Jun 27, 2021 · 1 comment

Comments

@yandaren
Copy link

// syncmap code:
	b.Run(fmt.Sprintf("%T", &IntMap{}), func(b *testing.B) {
		m := &IntMap{}
		// setup:

		// reset:
		b.ResetTimer()

		// perG:
		perG := func(b *testing.B, pb *testing.PB, i int, m *IntMap) {
			for ; pb.Next(); i++ {
				m.Range(func(_, _ int) bool { return true })
			}
		}
		var i int64
		b.RunParallel(func(pb *testing.PB) {
			id := int(atomic.AddInt64(&i, 1) - 1)
			perG(b, pb, id*b.N, m)
		})
	})

seems the setup function is nil, then the map is empy, so at the benrchmark result, it seems vary fast

@a8m
Copy link
Owner

a8m commented Jun 30, 2021

Hey @yandaren, you're right. Some parts are missing there (my fault), but some parts are empty in purpose.

Would you like to send a patch to fix this? It's basically a changed version of sync/map_bench_test.go. If don't have time, it's fine, I can address this soon. Thanks 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants