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
Copy file name to clipboardExpand all lines: README.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,3 +28,71 @@ Note that it is allowed to pass to the `PutXxx` functions objects that have been
28
28
rp:= httputil.NewSingleHostReverseProxy(target)
29
29
rp.BufferPool = bytespool.GetBufferPool(32*1024)
30
30
```
31
+
32
+
## Benchmarks
33
+
34
+
There is a small set of benchmarks you can run with `make bench` (you need to have [`benchstat`](https://golang.org/x/perf/cmd/benchstat) on your `PATH`), from which you can validate that in steady state no allocations are performed even for `[]byte`:
35
+
36
+
```
37
+
name time/op
38
+
GetBytesSlice-12 8.56ns ±14%
39
+
GetBytesSliceSemiStatic-12 8.26ns ±14%
40
+
GetBytesSliceStatic-12 8.19ns ±16%
41
+
GetBytesSlicePtr-12 5.18ns ±23%
42
+
GetBytesSlicePtrSemiStatic-12 4.74ns ±22%
43
+
GetBytesSlicePtrStatic-12 4.74ns ±22%
44
+
GetBytesBuffer-12 3.64ns ± 8%
45
+
GetBytesBufferSemiStatic-12 3.18ns ± 5%
46
+
GetBytesBufferStatic-12 3.12ns ± 5%
47
+
GetBufioReader-12 5.82ns ± 7%
48
+
GetBufioReaderSemiStatic-12 5.45ns ±10%
49
+
GetBufioReaderStatic-12 5.39ns ± 6%
50
+
GetBufioWriter-12 4.02ns ± 2%
51
+
GetBufioWriterSemiStatic-12 3.73ns ± 4%
52
+
GetBufioWriterStatic-12 3.56ns ± 3%
53
+
54
+
name alloc/op
55
+
GetBytesSlice-12 0.00B
56
+
GetBytesSliceSemiStatic-12 0.00B
57
+
GetBytesSliceStatic-12 0.00B
58
+
GetBytesSlicePtr-12 0.00B
59
+
GetBytesSlicePtrSemiStatic-12 0.00B
60
+
GetBytesSlicePtrStatic-12 0.00B
61
+
GetBytesBuffer-12 0.00B
62
+
GetBytesBufferSemiStatic-12 0.00B
63
+
GetBytesBufferStatic-12 0.00B
64
+
GetBufioReader-12 0.00B
65
+
GetBufioReaderSemiStatic-12 0.00B
66
+
GetBufioReaderStatic-12 0.00B
67
+
GetBufioWriter-12 0.00B
68
+
GetBufioWriterSemiStatic-12 0.00B
69
+
GetBufioWriterStatic-12 0.00B
70
+
71
+
name allocs/op
72
+
GetBytesSlice-12 0.00
73
+
GetBytesSliceSemiStatic-12 0.00
74
+
GetBytesSliceStatic-12 0.00
75
+
GetBytesSlicePtr-12 0.00
76
+
GetBytesSlicePtrSemiStatic-12 0.00
77
+
GetBytesSlicePtrStatic-12 0.00
78
+
GetBytesBuffer-12 0.00
79
+
GetBytesBufferSemiStatic-12 0.00
80
+
GetBytesBufferStatic-12 0.00
81
+
GetBufioReader-12 0.00
82
+
GetBufioReaderSemiStatic-12 0.00
83
+
GetBufioReaderStatic-12 0.00
84
+
GetBufioWriter-12 0.00
85
+
GetBufioWriterSemiStatic-12 0.00
86
+
GetBufioWriterStatic-12 0.00
87
+
```
88
+
89
+
## Developing
90
+
91
+
Most of the code is in `gen/main.go`. You can run `make generate` to generate `bytespool.go`.
92
+
93
+
## TODO
94
+
95
+
- Split low-level APIs in a separate package
96
+
- Ensure that users of the low-level API are not forced to compile also the high-level APIs
97
+
- Define BufferPool-like interfaces for all objects (e.g. BytesBufferPool)
0 commit comments