pointfreeco / swift-parsing

A library for turning nebulous data into well-structured data, with a focus on composition, performance, generality, and ergonomics.
https://www.pointfree.co/collections/parsing
MIT License
864 stars 77 forks source link

Improve `Date` parser demo #305

Closed stephencelis closed 1 year ago

stephencelis commented 1 year ago

Incorporates a helper from @juri's parser to improve things in our demo a bit.

Benchmarked against Parse3339 here and it's nice to see how well the relatively naive combinators performed by comparison:

name                      time         std        iterations
------------------------------------------------------------
Date.Parser                3583.000 ns ±  18.18 %     355076
Date.Parse3339             3083.000 ns ±  19.16 %     448056
Date.DateFormatter        21708.000 ns ±   7.24 %      63634
Date.ISO8601DateFormatter 26958.000 ns ±   5.17 %      51322
stephencelis commented 1 year ago

@BobbyRohweder I'm not sure how you're measuring it, but DateComponents.date is quite a bit slower:

Date.Parser (tm)                   3583.000 ns ±  18.18 %     355076
Date.Parser (DateComponents.date) 10750.000 ns ±  11.59 %     120687