A fast, safe, and efficient CBOR serialization library for Swift on any platform. swiftpackageindex.com/thecoolwinter/CBOR/1.1.1/documentation/cbor
atproto swift cbor

Update README

+29 -27
+2
Benchmarks/table.py
··· 1 + # I'd love for this to work but it's not quite right right now. The table in the README is copied manually. 2 + 1 3 import re 2 4 3 5 def to_ns(val, unit):
+27 -27
README.md
··· 7 7 8 8 [CBOR](https://cbor.io/) is a flexible data format that emphasizes extremely small code size, small message size, and extendability. This library provides a Swift API for encoding and decoding Swift types using the CBOR serialization format. 9 9 10 - The motivation for this library over existing implementations is twofold: performance, and reliability. Existing community implementations do not make correct use of Swift features like `Optional` and memory safety. This library aims to be safe while still outperforming other implementations. To that end, this library has been extensively [fuzz tested](./Fuzzing.md) to ensure your application never crashes due to malicious input. At the same time, this library boasts up to a *74% faster* encoding and up to *89% faster* decoding than existing implementations. See [benchmarks](#benchmarks) for more details. 10 + The motivation for this library over existing implementations is twofold: performance, and reliability. Existing community implementations do not make correct use of Swift features like `Optional` and memory safety. This library aims to be safe while still outperforming other implementations. To that end, this library has been extensively [fuzz tested](./Fuzz.md) to ensure your application never crashes due to malicious input. At the same time, this library boasts up to a *74% faster* encoding and up to *89% faster* decoding than existing implementations. See [benchmarks](#benchmarks) for more details. 11 11 12 12 ## Usage 13 13 ··· 78 78 79 79 | Benchmark | SwiftCBOR (ns, p50) | CBOR (ns, p50) | % Improvement | 80 80 |-----------|----------------|-----------|------------| 81 - | Array | 23 | 7 | **69.57%** | 82 - | Complex Object | 700,000 | 74,000 | **89.43%** | 83 - | Date | 5,211 | 1,042 | **80.00%** | 84 - | Dictionary | 17 | 5 | **70.59%** | 85 - | Double | 5,251 | 1,000 | **80.96%** | 86 - | Float | 5,251 | 1,000 | **80.96%** | 87 - | Indeterminate String | 6,251 | 1,375 | **78.00%** | 88 - | Int | 5,211 | 1,124 | **78.43%** | 89 - | Int Small | 5,167 | 1,083 | **79.04%** | 90 - | Simple Object | 36 | 8 | **77.78%** | 91 - | String | 5,419 | 1,251 | **76.91%** | 92 - | String Small | 5,251 | 1,125 | **78.58%** | 81 + | Array | 23 | 7 | **70%** | 82 + | Complex Object | 703 μs | 75 μs | **89%** | 83 + | Date | 5,251 | 1,083 | **79%** | 84 + | Dictionary | 17 | 5 | **71%** | 85 + | Double | 5,295 | 1,001 | **81%** | 86 + | Float | 5,295 | 1,000 | **81%** | 87 + | Indeterminate String | 6,251 | 1,417 | **77%** | 88 + | Int | 5,211 | 1,125 | **78%** | 89 + | Int Small | 5,211 | 1,083 | **79%** | 90 + | Simple Object | 36 | 8 | **78%** | 91 + | String | 5,459 | 1,292 | **76%** | 92 + | String Small | 5,291 | 1,126 | **79%** | 93 93 94 94 ### Encoding (cpu time) 95 95 96 - | Benchmark | SwiftCBOR (ns, p50) | CBOR (ns, p50) | % Improvement | 96 + | Benchmark | SwiftCBOR (ns, p50) | CBOR (ns, p50) | % Improvement | 97 97 |-----------|----------------|-----------|------------| 98 - | Array | 666,000 | 471,000 | **29.28%** | 99 - | Array Small | 7,003 | 2,875 | **58.95%** | 100 - | Bool | 3,167 | 1,124 | **64.51%** | 101 - | Complex Codable Object | 124,000 | 92,000 | **25.81%** | 102 - | Data | 5,295 | 1,208 | **77.19%** | 103 - | Data Small | 3,917 | 959 | **75.52%** | 104 - | Dictionary | 11 | 5 | **54.55%** | 105 - | Dictionary Small | 7,419 | 2,875 | **61.25%** | 106 - | Int | 3,959 | 1,291 | **67.39%** | 107 - | Int Small | 3,793 | 1,208 | **68.15%** | 108 - | Simple Codable Object | 18 | 9 | **50.00%** | 109 - | String | 5,543 | 1,250 | **77.45%** | 110 - | String Small | 4,001 | 1,125 | **71.88%** | 98 + | Array | 669 μs | 471 μs | **30%** | 99 + | Array Small | 7,043 | 2,917 | **59%** | 100 + | Bool | 3,169 | 1,125 | **64%** | 101 + | Complex Codable Object | 124 μs | 92 μs | **26%** | 102 + | Data | 5,335 | 1,250 | **77%** | 103 + | Data Small | 3,959 | 1000 | **75%** | 104 + | Dictionary | 11 | 5 | **55%** | 105 + | Dictionary Small | 7,459 | 2,959 | **60%** | 106 + | Int | 4,001 | 1,292 | **68%** | 107 + | Int Small | 3,833 | 1,208 | **68%** | 108 + | Simple Codable Object | 18 | 9 | **50%** | 109 + | String | 5,583 | 1,291 | **77%** | 110 + | String Small | 4,041 | 1,125 | **72%** | 111 111 112 112 ## Contributing 113 113