File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
examples/advanced/zeromemorycopy Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 99 "unsafe"
1010
1111 "github.com/devlights/gomy/times"
12+ "github.com/devlights/gomy/zeromemcpy"
1213)
1314
1415// ByteSliceToString -- バイトスライスから文字列へメモリコピー無しに変換するサンプルです。
@@ -63,5 +64,13 @@ func ByteSliceToString() error {
6364 })
6465 fmt .Printf ("[zeromemcpy] %v\n " , elapsed )
6566
67+ // -------------------------------------
68+ // zeromemcpy.b2s
69+ // -------------------------------------
70+ elapsed = times .Stopwatch (func (start time.Time ) {
71+ io .WriteString (io .Discard , zeromemcpy .B2S (b ))
72+ })
73+ fmt .Printf ("[zeromemcpy.B2S] %v\n " , elapsed )
74+
6675 return nil
6776}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "unsafe"
1111
1212 "github.com/devlights/gomy/times"
13+ "github.com/devlights/gomy/zeromemcpy"
1314)
1415
1516// StringToByteSlice -- 文字列からバイトスライスへメモリコピー無しに変換するサンプルです。
@@ -66,5 +67,13 @@ func StringToByteSlice() error {
6667 })
6768 fmt .Printf ("[zeromemcpy] %v\n " , elapsed )
6869
70+ // -------------------------------------
71+ // zeromemcpy.s2b
72+ // -------------------------------------
73+ elapsed = times .Stopwatch (func (start time.Time ) {
74+ io .Discard .Write (zeromemcpy .S2B (s ))
75+ })
76+ fmt .Printf ("[zeromemcpy.s2b] %v\n " , elapsed )
77+
6978 return nil
7079}
You can’t perform that action at this time.
0 commit comments