| 123456789101112131415161718192021222324252627282930313233 |
- package util
- import (
- "fmt"
- "testing"
- "time"
- )
- func TestSubTimeToSeconds(t *testing.T) {
- now := time.Now()
- time.Sleep(time.Microsecond * 100)
- t.Log(SubTimeToSeconds(now, time.Now()))
- }
- /**
- BenchmarkStringFmt-12 8401734 158 ns/op 48 B/op 3 allocs/op
- BenchmarkStringConn-12 69749120 19.0 ns/op 0 B/op 0 allocs/op
- */
- func BenchmarkStringFmt(b *testing.B) {
- str1 := "11111"
- str2 := "22222"
- for i := 0; i < b.N; i++ {
- fmt.Sprintf("%s%s", str1, str2)
- }
- }
- func BenchmarkStringConn(b *testing.B) {
- str1 := "11111"
- str2 := "22222"
- for i := 0; i < b.N; i++ {
- _ = str1 + str2
- }
- }
|