Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pkg/ottl] Improve time performance (#35129)
**Description:** Improves `Time` performance by move the conversion from our format to Go's format to happen during startup. Benchmarks before: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs Benchmark_Time/simple_short_form-10 1000000000 0.0000079 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_short_form_with_short_year_and_slashes-10 1000000000 0.0000115 ns/op 0 B/op 0 allocs/op Benchmark_Time/month_day_year-10 1000000000 0.0000057 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_long_form-10 1000000000 0.0000075 ns/op 0 B/op 0 allocs/op Benchmark_Time/date_with_timestamp-10 1000000000 0.0000063 ns/op 0 B/op 0 allocs/op Benchmark_Time/day_of_the_week_long_form-10 1000000000 0.0000085 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_weekday,_short_month,_long_format-10 1000000000 0.0000089 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_months-10 1000000000 0.0000070 ns/op 0 B/op 0 allocs/op Benchmark_Time/timestamp_with_time_zone_offset-10 1000000000 0.0000665 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_date_with_timestamp_without_time_zone_offset-10 1000000000 0.0000428 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format-10 1000000000 0.0000345 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000-10 1000000000 0.0000349 ns/op 0 B/op 0 allocs/op Benchmark_Time/no_location-10 1000000000 0.0000035 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_America-10 1000000000 0.0000104 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_Asia-10 1000000000 0.0000084 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000,_ignore_default_location-10 1000000000 0.0000379 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs 0.458s ``` Benchmark's after: ``` goos: darwin goarch: arm64 pkg: github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs Benchmark_Time/simple_short_form-10 1000000000 0.0000054 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_short_form_with_short_year_and_slashes-10 1000000000 0.0000037 ns/op 0 B/op 0 allocs/op Benchmark_Time/month_day_year-10 1000000000 0.0000053 ns/op 0 B/op 0 allocs/op Benchmark_Time/simple_long_form-10 1000000000 0.0000042 ns/op 0 B/op 0 allocs/op Benchmark_Time/date_with_timestamp-10 1000000000 0.0000087 ns/op 0 B/op 0 allocs/op Benchmark_Time/day_of_the_week_long_form-10 1000000000 0.0000035 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_weekday,_short_month,_long_format-10 1000000000 0.0000036 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_months-10 1000000000 0.0000031 ns/op 0 B/op 0 allocs/op Benchmark_Time/timestamp_with_time_zone_offset-10 1000000000 0.0000491 ns/op 0 B/op 0 allocs/op Benchmark_Time/short_date_with_timestamp_without_time_zone_offset-10 1000000000 0.0000381 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format-10 1000000000 0.0000365 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000-10 1000000000 0.0000364 ns/op 0 B/op 0 allocs/op Benchmark_Time/no_location-10 1000000000 0.0000028 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_America-10 1000000000 0.0000017 ns/op 0 B/op 0 allocs/op Benchmark_Time/with_location_-_Asia-10 1000000000 0.0000028 ns/op 0 B/op 0 allocs/op Benchmark_Time/RFC_3339_in_custom_format_before_2000,_ignore_default_location-10 1000000000 0.0000393 ns/op 0 B/op 0 allocs/op PASS ok github.com/open-telemetry/opentelemetry-collector-contrib/pkg/ottl/ottlfuncs 0.441s ``` **Link to tracking Issue:** <Issue number if applicable> Closes #35078 **Testing:** <Describe what testing was performed and which tests were added.> Added benchmark test
- Loading branch information