Inlinable Codable

I made a benchmark project to compare inlinable version vs non inlinable.

The results are following:

name                                          time           std        iterations
----------------------------------------------------------------------------------
Encode (no inline)                            1054396.000 ns ±   3.25 %       1286
Encode (inline)                                420666.500 ns ±   3.57 %       3292
Decode (no inline)                             820250.000 ns ±   3.20 %       1689
Decode (inline)                                466583.000 ns ±   3.63 %       2972
Decode json with ZippyJSONDecoder (no inline)  246625.000 ns ±   5.70 %       5568
Decode json with ZippyJSONDecoder (inline)     176833.500 ns ±   5.75 %       7798

So there are clear differences between versions. But I also should mention that forcing the compiler to actually inline everything is quite tricky and requires a lot of attention from all parties: stdlib, the encoder/decoder vendor and the consumer. But at least it's possible.
One of the most tricky thing is that I have to keep signatures of the encode(to: Encoder) and init(from: Decoder) to not break ABI. So they are not generic and all of the inlining magic around them is kinda fragile.

3 Likes