(b *testing.B)
| 1535 | } |
| 1536 | |
| 1537 | func BenchmarkNativeToValue(b *testing.B) { |
| 1538 | env := testNativeEnv(b) |
| 1539 | adapter := env.CELTypeAdapter() |
| 1540 | |
| 1541 | nested := &TestNestedType{ |
| 1542 | NestedListVal: []string{"a", "b", "c"}, |
| 1543 | NestedMapVal: map[int64]bool{1: true}, |
| 1544 | NestedCustomName: "test", |
| 1545 | } |
| 1546 | allTypes := &TestAllTypes{ |
| 1547 | BoolVal: true, |
| 1548 | Int32Val: 10, |
| 1549 | Int64Val: 20, |
| 1550 | StringVal: "hello world", |
| 1551 | NestedVal: nested, |
| 1552 | ListVal: []*TestNestedType{nested}, |
| 1553 | } |
| 1554 | allTypesSlice := []*TestAllTypes{allTypes, allTypes} |
| 1555 | |
| 1556 | benchmarks := []struct { |
| 1557 | name string |
| 1558 | val any |
| 1559 | }{ |
| 1560 | {name: "TestNestedType", val: nested}, |
| 1561 | {name: "TestAllTypes", val: allTypes}, |
| 1562 | {name: "SliceTestAllTypes", val: allTypesSlice}, |
| 1563 | } |
| 1564 | |
| 1565 | for _, bm := range benchmarks { |
| 1566 | b.Run(bm.name, func(b *testing.B) { |
| 1567 | b.ResetTimer() |
| 1568 | b.ReportAllocs() |
| 1569 | for i := 0; i < b.N; i++ { |
| 1570 | adapter.NativeToValue(bm.val) |
| 1571 | } |
| 1572 | }) |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | func BenchmarkConvertToNative(b *testing.B) { |
| 1577 | env := testNativeEnv(b) |
nothing calls this directly
no test coverage detected