1
0
mirror of https://github.com/open-telemetry/opentelemetry-go.git synced 2024-12-26 21:05:00 +02:00
opentelemetry-go/internal/attribute
Warnar Boekkooi 9f82e51c89
Performance improvements for attribute value AsStringSlice, AsFloat64Slice, AsInt64Slice, AsBoolSlice (#6011)
Good day,

This PR changes As[Bool|Int64|Float64|String]Slice to use a little less
reflection.

The benchstat result of this is as follows.
```
goos: linux
goarch: amd64
pkg: go.opentelemetry.io/otel/internal/attribute
cpu: AMD Ryzen 7 Pro 7735U with Radeon Graphics     
                  │   org.txt    │               new.txt                │
                  │    sec/op    │    sec/op     vs base                │
AsFloat64Slice-16   373.3n ± 41%   181.0n ± 42%  -51.51% (p=0.000 n=10)

                  │  org.txt   │              new.txt               │
                  │    B/op    │    B/op     vs base                │
AsFloat64Slice-16   64.00 ± 0%   40.00 ± 0%  -37.50% (p=0.000 n=10)

                  │  org.txt   │              new.txt               │
                  │ allocs/op  │ allocs/op   vs base                │
AsFloat64Slice-16   3.000 ± 0%   2.000 ± 0%  -33.33% (p=0.000 n=10)
```

---------

Co-authored-by: Damien Mathieu <42@dmathieu.com>
2024-12-03 09:46:16 +01:00
..
attribute_test.go Performance improvements for attribute value AsStringSlice, AsFloat64Slice, AsInt64Slice, AsBoolSlice (#6011) 2024-12-03 09:46:16 +01:00
attribute.go Performance improvements for attribute value AsStringSlice, AsFloat64Slice, AsInt64Slice, AsBoolSlice (#6011) 2024-12-03 09:46:16 +01:00