You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Interface equality check is expensive compared to integer comparison check.
In the benchmark, I compare two integers. I then wrap them in interface{} and compare
them.
As interface{}, the comparison check takes over 20X the time taken by just plain
comparison check.
See http://play.golang.org/p/1evwkTYYlB
Results:
BenchmarkIntfEqual 100000000 14.5 ns/op
BenchmarkReflectTypeEqual 100000000 14.4 ns/op
BenchmarkPtrEqual 2000000000 1.06 ns/op
BenchmarkIntEqual 2000000000 0.70 ns/op
BenchmarkIntMapAccess 500000000 5.22 ns/op
BenchmarkReflectTypeMapAccess 50000000 57.6 ns/op
BenchmarkIntMapAccessMiss 100000000 16.4 ns/op
BenchmarkReflectTypeMapAccessMiss 50000000 58.3 ns/op
Which compiler are you using (5g, 6g, 8g, gccgo)?
6g
Which operating system are you using?
Linux 3.8.0-27-generic #40-Ubuntu SMP Tue Jul 9 00:17:05 UTC 2013 x86_64 x86_64 x86_64
GNU/Linux
Which version are you using? (run 'go version')
go version devel +21ae2c5817da Fri Aug 09 23:23:34 2013 +1000 linux/amd64
Please provide any additional information below.
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: