5f877c52fdf65fceca9680ab38e6bcc78ef9b02f
Adding several files to stress test the unmarshaller. Most were converted from JSON so they may not be very realistic use cases. ``` goos: linux goarch: amd64 pkg: github.com/pelletier/go-toml/v2/benchmark cpu: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz BenchmarkUnmarshalDataset/config/v2-2 16 66339063 ns/op 15.81 MB/s 16850159 B/op 645454 allocs/op BenchmarkUnmarshalDataset/config/v1-2 7 147289186 ns/op 7.12 MB/s 60669811 B/op 870486 allocs/op BenchmarkUnmarshalDataset/config/bs-2 12 88966009 ns/op 11.79 MB/s 29949268 B/op 705573 allocs/op BenchmarkUnmarshalDataset/canada/v2-2 8 145433377 ns/op 15.14 MB/s 74282227 B/op 895641 allocs/op BenchmarkUnmarshalDataset/canada/v1-2 3 434913677 ns/op 5.06 MB/s 138664290 B/op 1897300 allocs/op BenchmarkUnmarshalDataset/citm_catalog/v2-2 19 55256979 ns/op 10.10 MB/s 37122952 B/op 369492 allocs/op BenchmarkUnmarshalDataset/citm_catalog/v1-2 10 110343191 ns/op 5.06 MB/s 54743595 B/op 727704 allocs/op BenchmarkUnmarshalDataset/citm_catalog/bs-2 21 51634081 ns/op 10.81 MB/s 17196872 B/op 325830 allocs/op BenchmarkUnmarshalDataset/twitter/v2-2 50 26660937 ns/op 16.57 MB/s 15580238 B/op 156394 allocs/op BenchmarkUnmarshalDataset/twitter/v1-2 30 43128488 ns/op 10.25 MB/s 21203420 B/op 266110 allocs/op BenchmarkUnmarshalDataset/twitter/bs-2 48 27337976 ns/op 16.16 MB/s 8795405 B/op 145370 allocs/op BenchmarkUnmarshalDataset/code/v2-2 4 276279202 ns/op 9.71 MB/s 59293948 B/op 2907227 allocs/op BenchmarkUnmarshalDataset/code/v1-2 3 421910642 ns/op 6.36 MB/s 161733770 B/op 2478194 allocs/op BenchmarkUnmarshalDataset/code/bs-2 4 323158157 ns/op 8.31 MB/s 133056988 B/op 1439475 allocs/op BenchmarkUnmarshalDataset/example/v2-2 2444 479553 ns/op 16.89 MB/s 237606 B/op 3609 allocs/op BenchmarkUnmarshalDataset/example/v1-2 1321 911995 ns/op 8.88 MB/s 377502 B/op 6133 allocs/op BenchmarkUnmarshalDataset/example/bs-2 1898 555649 ns/op 14.58 MB/s 178485 B/op 3362 allocs/op BenchmarkUnmarshalSimple/v2-2 896760 1200 ns/op BenchmarkUnmarshalSimple/v1-2 207364 6070 ns/op BenchmarkUnmarshalSimple/bs-2 420952 2925 ns/op BenchmarkReferenceFile/v2-2 29473 39433 ns/op 132.93 MB/s 11812 B/op 253 allocs/op BenchmarkReferenceFile/v1-2 2823 361383 ns/op 14.51 MB/s 136470 B/op 2745 allocs/op BenchmarkReferenceFile/bs-2 3097 391116 ns/op 13.40 MB/s 80795 B/op 1729 allocs/op PASS ok github.com/pelletier/go-toml/v2/benchmark 34.255s ```
go-toml V2
Development branch. Use at your own risk.
toml.Unmarshal()should work as well as v1.
Must do
Unmarshal
- Unmarshal into maps.
- Support Array Tables.
- Unmarshal into pointers.
- Support Date / times.
- Support struct tags annotations.
- Support Arrays.
- Support Unmarshaler interface.
- Original go-toml unmarshal tests pass.
- Benchmark!
- Abstract AST.
- Original go-toml testgen tests pass.
- Track file position (line, column) for errors.
- Strict mode.
Marshal
- Minimal implementation
Document
- Gather requirements and design API.
Ideas
- Allow types to implement a
ASTUnmarshalerinterface to unmarshal straight from the AST? - Rewrite AST to use a single array as storage instead of one allocation per node.
- Provide "minimal allocations" option that uses
unsafeto reuse the input byte array as storage for strings. - Cache reflection operations per type.
- Optimize tracker pass.
Differences with v1
License
The MIT License (MIT). Read LICENSE.
Description
Languages
Go
94.6%
Shell
5.4%