Commit Graph

7 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
eaedadbed0
replace strings.Split(N) for strings.Cut() or alternatives
Go 1.18 and up now provides a strings.Cut() which is better suited for
splitting key/value pairs (and similar constructs), and performs better:

```go
func BenchmarkSplit(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _ = strings.SplitN(s, "=", 2)[0]
                }
        }
}

func BenchmarkCut(b *testing.B) {
        b.ReportAllocs()
        data := []string{"12hello=world", "12hello=", "12=hello", "12hello"}
        for i := 0; i < b.N; i++ {
                for _, s := range data {
                        _, _, _ = strings.Cut(s, "=")
                }
        }
}
```

    BenchmarkSplit
    BenchmarkSplit-10            8244206               128.0 ns/op           128 B/op          4 allocs/op
    BenchmarkCut
    BenchmarkCut-10             54411998                21.80 ns/op            0 B/op          0 allocs/op

While looking at occurrences of `strings.Split()`, I also updated some for alternatives,
or added some constraints; for cases where an specific number of items is expected, I used `strings.SplitN()`
with a suitable limit. This prevents (theoretical) unlimited splits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-11-07 10:02:25 +01:00
Eric Ernst
ac2692d30f containerd-stress: introduce option for specifying image
allow user to specify what image should be used for containerd-stress.

Signed-off-by: Eric Ernst <eric_ernst@apple.com>
2022-02-06 09:55:16 -08:00
ningmingxiao
ed0828bb6b
delete useless code
Signed-off-by: ningmingxiao <ning.mingxiao@zte.com.cn>
2022-01-18 21:10:20 +08:00
Eng Zer Jun
50da673592
refactor: move from io/ioutil to io and os package
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-09-21 09:50:38 +08:00
Alakesh Haloi
0550c32330 containerd-stress: add snapshotter option for stress test to use
containerd-stress utility needs to be able to run with snapshotter
passed by user in cli in order to be able to stress test snapshotters.
This adds a cli option --snapshotter="<snapshotter-name>"

Signed-off-by: Alakesh Haloi <alakeshh@amazon.com>
2021-04-12 20:45:22 +00:00
Michael Crosby
fd6299be98 Fix density spec generation
Fixes #3580

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2019-09-17 16:21:25 -04:00
Michael Crosby
a2ef6952f2 Add density stress test
Running the density tool will report Pss and Rss total and per container
values for shim memory usage. Values are reported in KB.

```bash
containerd-stress density --count 500
INFO[0000] pulling docker.io/library/alpine:latest
INFO[0000] generating spec from image
{"pss":421188,"rss":2439688,"pssPerContainer":842,"rssPerContainer":4879}
```

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2018-02-27 16:40:37 -05:00