github.com/Anderson-Lu/gobox@v0.0.0-20191127065433-3e6c4c2da420/application/application_test.go (about) 1 package application 2 3 import ( 4 "testing" 5 ) 6 7 func BenchmarkTypeConvert1(b *testing.B) { 8 var d interface{} = 1 9 var total = 0 10 b.StartTimer() 11 for i := 0; i < 1000000; i++ { 12 total += d.(int) 13 } 14 15 b.StopTimer() 16 } 17 18 func BenchmarkTypeConvert2(b *testing.B) { 19 var d int = 1 20 var total = 0 21 b.StartTimer() 22 for i := 0; i < 1000000; i++ { 23 total += d 24 } 25 26 b.StopTimer() 27 }