| 159 | } |
| 160 | |
| 161 | func BenchmarkBlockMetaMarshalUnmarshal(b *testing.B) { |
| 162 | timeParse := func(s string) time.Time { |
| 163 | date, err := time.Parse(time.RFC3339Nano, s) |
| 164 | require.NoError(b, err) |
| 165 | return date |
| 166 | } |
| 167 | |
| 168 | meta := BlockMeta{ |
| 169 | Version: "vParquet3", |
| 170 | BlockID: MustParse("00000000-0000-0000-0000-000000000000"), |
| 171 | TenantID: "single-tenant", |
| 172 | StartTime: timeParse("2021-01-01T00:00:00.0000000Z"), |
| 173 | EndTime: timeParse("2021-01-02T00:00:00.0000000Z"), |
| 174 | TotalObjects: 10, |
| 175 | Size_: 12345, |
| 176 | CompactionLevel: 1, |
| 177 | IndexPageSize: 250000, |
| 178 | TotalRecords: 124356, |
| 179 | BloomShardCount: 244, |
| 180 | FooterSize: 15775, |
| 181 | DedicatedColumns: DedicatedColumns{ |
| 182 | {Scope: "resource", Name: "namespace", Type: "string"}, |
| 183 | {Scope: "resource", Name: "net.host.port", Type: "int"}, |
| 184 | {Scope: "span", Name: "http.method", Type: "string"}, |
| 185 | {Scope: "span", Name: "namespace", Type: "string"}, |
| 186 | {Scope: "span", Name: "http.response.body.size", Type: "int"}, |
| 187 | {Scope: "span", Name: "http.request.header.accept", Type: "string", Options: DedicatedColumnOptions{DedicatedColumnOptionArray}}, |
| 188 | |
| 189 | {Name: "test.span.str-01", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 190 | {Name: "test.span.str-02", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 191 | {Name: "test.span.str-03", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 192 | {Name: "test.span.str-04", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 193 | {Name: "test.span.str-05", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 194 | {Name: "test.span.str-06", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 195 | {Name: "test.span.str-07", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 196 | {Name: "test.span.str-08", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 197 | {Name: "test.span.str-09", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 198 | {Name: "test.span.str-10", Scope: DedicatedColumnScopeSpan, Type: DedicatedColumnTypeString}, |
| 199 | }, |
| 200 | } |
| 201 | |
| 202 | b.Run("marshal", func(b *testing.B) { |
| 203 | _, err := meta.Marshal() |
| 204 | require.NoError(b, err, "marshal should not fail") |
| 205 | for b.Loop() { |
| 206 | meta.Marshal() // nolint:errcheck // skipping error check for benchmark, checked above |
| 207 | } |
| 208 | }) |
| 209 | |
| 210 | b.Run("unmarshal", func(b *testing.B) { |
| 211 | data, err := meta.Marshal() |
| 212 | require.NoError(b, err) |
| 213 | require.NoError(b, meta.Unmarshal(data), "unmarshal should not fail") |
| 214 | |
| 215 | for b.Loop() { |
| 216 | meta.Unmarshal(data) // nolint:errcheck // skipping error check for benchmark, checked above |
| 217 | } |
| 218 | }) |