-
Notifications
You must be signed in to change notification settings - Fork 9
/
cast.exs
19 lines (18 loc) · 940 Bytes
/
cast.exs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
string = Ecto.ParameterizedType.init(Ch, type: "String")
int64 = Ecto.ParameterizedType.init(Ch, type: "Int64")
nullable_string = Ecto.ParameterizedType.init(Ch, type: "Nullable(String)")
low_cardinality_string = Ecto.ParameterizedType.init(Ch, type: "LowCardinality(String)")
tuple = Ecto.ParameterizedType.init(Ch, type: "Tuple(String, Int64)")
map = Ecto.ParameterizedType.init(Ch, type: "Map(String, UInt64)")
Benchee.run(
%{
"String" => fn -> Ecto.Type.cast(string, "value") end,
"Int64" => fn -> Ecto.Type.cast(int64, 10) end,
"Nullable(String)" => fn -> Ecto.Type.cast(nullable_string, "value") end,
"LowCardinality(String)" => fn -> Ecto.Type.cast(low_cardinality_string, "value") end,
"Tuple(String, Int64)" => fn -> Ecto.Type.cast(tuple, {"value", 10}) end,
"Map(String, UInt64)" => fn -> Ecto.Type.cast(map, %{"value" => 10}) end
},
measure_function_call_overhead: true
# profile_after: :eprof
)