mouse07410 / asn1c

The ASN.1 Compiler
http://lionet.info/asn1c/
BSD 2-Clause "Simplified" License
93 stars 70 forks source link

Copy operation #174

Closed v0-e closed 6 months ago

v0-e commented 6 months ago

Usually, if a user wants to copy an ASN.1 structure, the user first encodes the source structure and then decodes it into the destination structure. This works well, though is not really performant.

This PR introduces asn_copy() to speed up structure deep-copying without the encoding/decoding overhead.

A benchmark of copying a zero-initialized ETSI ITS CAM (definition) 1000000 times, with some fields set to 1 to pass constraint checks. Encoding/decoding roundtrip-based copy results are also shown.

Cloning CAM 1000000 times
Copy in 0.263973 s
COER in 3.683888 s
BER  in 14.686351 s
UPER in 3.921389 s
JERM in 10.551459 s
CXER in 14.745492 s