Benchmarks for swift-yyjson, comparing performance against Foundation's JSON APIs.
- Swift 6.1+
- macOS 26+
Download the JSON test fixtures:
make fixturesThis downloads standard JSON benchmark files from nativejson-benchmark:
twitter.json(~632KB) - Twitter API response with nested objects and CJK textcitm_catalog.json(~1.7MB) - Large catalog with many string keyscanada.json(~2.2MB) - GeoJSON with many floating-point coordinatestokenizer.json(~11MB) - HuggingFace tokenizer (mlx-community/Qwen3-0.6B-Base-DQ5) with large vocab and merges arrays
Run all benchmarks:
swift package benchmarkRun specific benchmark groups:
# Encoder/Decoder comparisons
swift package benchmark run --filter "Encoder"
swift package benchmark run --filter "Decoder"
# Serialization API comparisons
swift package benchmark run --filter "Serialization"
# Real-world fixture benchmarks
swift package benchmark run --filter "Fixture"
# Direct Value API benchmarks
swift package benchmark run --filter "Value"List all available benchmarks:
swift package benchmark listCompares YYJSONEncoder/YYJSONDecoder against Foundation's JSONEncoder/JSONDecoder using the Codable protocol.
- Simple: Small struct with basic types (string, int, double, bool)
- Nested: Struct with nested objects, arrays, and dictionaries
- Large: Deeply nested structure with multiple levels
Compares YYJSONSerialization against JSONSerialization for reading/writing untyped JSON ([String: Any]).
Benchmarks for YYJSONValue direct parsing and access:
- Parsing JSON to value representation
- Key/index-based access
- Object/array iteration
- Deep nested traversal
Real-world JSON files commonly used in JSON parser benchmarks.
Save a baseline:
swift package --allow-writing-to-package-directory benchmark baseline update defaultCompare against baseline:
swift package benchmark baseline compare defaultmake fixtures # Download test fixtures
make clean # Remove fixtures
make benchmark # Download fixtures and run benchmarks