github.com/webmafia/fast@v0.10.0/string_buffer_test.go (about) 1 package fast 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 func BenchmarkStringBuffer_WriteFloat64(b *testing.B) { 9 var buf StringBuffer 10 11 b.ResetTimer() 12 13 for i := 0; i < b.N; i++ { 14 buf.WriteFloat64(123.456789) 15 buf.Reset() 16 } 17 } 18 19 func BenchmarkStringBuffer_WriteFloat64Lossy(b *testing.B) { 20 var buf StringBuffer 21 22 b.ResetTimer() 23 24 for i := 0; i < b.N; i++ { 25 buf.WriteFloat64Lossy(123.456789) 26 buf.Reset() 27 } 28 } 29 30 func ExampleStringBuffer() { 31 var b StringBuffer 32 b.WriteString("hello") 33 b.WriteByte(' ') 34 b.WriteInt(123) 35 fmt.Println(b) 36 37 b.Reset() 38 39 b.WriteFloat64Lossy(123.4567891) 40 b.WriteByte(' ') 41 b.WriteBool(true) 42 fmt.Println(b) 43 44 // Output: 45 // hello 123 46 // 123.456789 true 47 }