diff options
| author | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-02 11:14:46 -0800 |
|---|---|---|
| committer | Josh Bleecher Snyder <josharian@gmail.com> | 2019-03-02 20:13:13 +0000 |
| commit | 06c86e0fc3eec6635fce31b8cd6b988087a8f872 (patch) | |
| tree | 6108c028f5c9d5afaa55e285190c9f8617e5e324 /src/os/exec/exec.go | |
| parent | beadf433c37498dafc6748cc510eeab2636b5be3 (diff) | |
| download | go-06c86e0fc3eec6635fce31b8cd6b988087a8f872.tar.xz | |
syscall: optimize SlicePtrFromStrings
Instead of allocating a byte slice for every string,
calculated the required size and create
a single slice big enough to hold all of them.
As an added benefit, any error encountered
will now be returned before allocations occur.
os/exec package benchmarks:
name old time/op new time/op delta
ExecEcho-8 2.14ms ± 1% 2.14ms ± 3% ~ (p=0.842 n=10+9)
name old alloc/op new alloc/op delta
ExecEcho-8 6.35kB ± 0% 6.18kB ± 0% -2.65% (p=0.000 n=10+10)
name old allocs/op new allocs/op delta
ExecEcho-8 69.0 ± 0% 36.0 ± 0% -47.83% (p=0.000 n=10+10)
Change-Id: I84118d8473037d873f73903d4e4f6ed14f531ce7
Reviewed-on: https://go-review.googlesource.com/c/164961
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/os/exec/exec.go')
0 files changed, 0 insertions, 0 deletions
