apple / swift-collections-benchmark

A benchmarking tool for Swift Collection algorithms
Apache License 2.0
346 stars 23 forks source link

This package should start using the stdlib's Clock and Duration types #21

Open lorentey opened 8 months ago

lorentey commented 8 months ago

Subject says it all -- this package should stop using platform-specific clock APIs (or delegating to Foundation.Date).

It's been a while since we added ContiguousClock/SuspendingClock/Duration to the stdlib, and the restricted availability of these types is less of an issue with every passing day, even on Apple platforms.

The primary difficulty is in making sure we preserve custom formatting of duration values, and that we don't break statistical calculations. Duration is a fixed-width integer count of attoseconds, which I expect to be just as good as or better than the current plain Double for doing the simple statistical calculations in this package -- but this needs to be verified in practice. (Some things could be tricky to express without relying on Int128...)

The format of saved benchmark results will likely need to change to reflect the change in duration representations. That is fine -- this package makes no promises on compatibility of previously saved results.