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

use maps.Equal instead of reflect.DeepEqual #1129

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

lrweck
Copy link
Contributor

@lrweck lrweck commented Jul 23, 2024

reflect causes a lot of memory allocations and uses more CPU time. maps.Equal does not cause any allocations and is about 80% faster

BenchmarkMapComparing/reflect.DeepEqual/10-8             1000000          1012 ns/op         320 B/op         30 allocs/op
BenchmarkMapComparing/maps.Equal/10-8                    7164884           170 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/20-8              629672          1899 ns/op         640 B/op         60 allocs/op
BenchmarkMapComparing/maps.Equal/20-8                    4098136           350 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/40-8              279854          3835 ns/op        1280 B/op        120 allocs/op
BenchmarkMapComparing/maps.Equal/40-8                    1950439           611 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/80-8              161636          7361 ns/op        2560 B/op        240 allocs/op
BenchmarkMapComparing/maps.Equal/80-8                    1000000          1157 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/100-8             128911          9429 ns/op        3200 B/op        300 allocs/op
BenchmarkMapComparing/maps.Equal/100-8                    840912          1421 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/200-8              65206         18791 ns/op        6400 B/op        600 allocs/op
BenchmarkMapComparing/maps.Equal/200-8                    424918          2888 ns/op           0 B/op          0 allocs/op
BenchmarkMapComparing/reflect.DeepEqual/400-8              33045         40529 ns/op       12800 B/op       1200 allocs/op
BenchmarkMapComparing/maps.Equal/400-8                    216856          5570 ns/op           0 B/op          0 allocs/op

reflect causes a lot of memory allocations and uses more CPU time.
maps.Equal does not cause any allocations and is about 80% faster
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.

1 participant