Skip to content

Comments

Remind count of map and add benchmark#142

Open
blight19 wants to merge 2 commits intoorcaman:masterfrom
blight19:master
Open

Remind count of map and add benchmark#142
blight19 wants to merge 2 commits intoorcaman:masterfrom
blight19:master

Conversation

@blight19
Copy link

@blight19 blight19 commented Jul 14, 2023

the old:
BenchmarkCount
BenchmarkCount-8 2150287 514.2 ns/op
the new:
BenchmarkCount
BenchmarkCount-8 393898780 2.755 ns/op

And otherwise ,the insert from
the new
BenchmarkItems-8 278 4242234 ns/op
the old
BenchmarkItems-8 258 4090206 ns/op

Fixes: #143

@blight19
Copy link
Author

#143

Comment on lines +73 to 74
b := len(shard.items)
shard.Lock()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to move it inside lock, because length can be changed by another thread

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

Successfully merging this pull request may close these issues.

performance of count

2 participants