Giter Club home page Giter Club logo

chronos's Introduction

Chronos

Windows build

Chronos is a performance-oriented time library for Haskell, with a straightforward API. The main differences between this and the time library are:

  • Chronos uses machine integers where possible. This means that time-related arithmetic should be faster, with the drawback that the types are incapable of representing times that are very far in the future or the past (because Chronos provides nanosecond, rather than picosecond, resolution). For most users, this is not a hindrance and the tradeoff is worthwhile.
  • Chronos provides 'ToJSON'/'FromJSON' instances for serialisation.
  • Chronos provides 'Unbox' instances for working with unboxed vectors.
  • Chronos provides 'Prim' instances for working with byte arrays/primitive arrays.
  • Chronos uses normal non-overloaded haskell functions for encoding and decoding time. It provides attoparsec parsers for both 'Text' and 'ByteString'. Additionally, Chronos provides functions for encoding time to 'Text' or 'ByteString'. The time library accomplishes these with the Data.Time.Format module, which uses UNIX-style datetime format strings. The approach taken by Chronos is faster and catches more mistakes at compile time, at the cost of being less expressive.

Jacob Stanley has written a blog post comparing the features and performance of time, thyme, and chronos. It has a good bulleted breakdown of why you may want to use each library along with some benchmarks.

Benchmarks

Benchmarks of chronos against time and thyme.

Parsing

Benchmark name Time
Time.parseTimeM 9.679 μs
Thyme.parseTime 1.743 μs
Thyme.timeParser 1.113 μs
Chronos.parserUtf8_YmdHMS 301.4 ns
Chronos.zeptoUtf8_YmdHMS 173.6 ns

Pretty-printing

Benchmark name Time
dmy/Time.formatTime 4.404 μs
dmy/Thyme.formatTime 663.0 ns
dmy/Chronos.builder_Dmy 340.9 ns
HMS/Time.formatTime 1.987 μs
HMS/Thyme.formatTime 879.1 ns
HMS/Chronos.builder_HMS 481.3 ns

Doctest

Doctest used to be provided as a test suite, but doctest-0.20 and higher do not require this to be run. To run the doctests, make sure you have doctest on your path (i.e. run cabal install doctest), and then run:

cabal build
cabal repl --build-depends=QuickCheck --with-ghc=doctest --repl-options='-fno-warn-orphans'

This runs incredibly slowly, but it works for now. Doctest is not run by CI, so if you make a change that adds more doctests, it needs to be run by hand by someone. (The maintainer is happy to do this if you're on a platform where doctest is finicky.)

chronos's People

Contributors

aljce avatar andrewthad avatar avieth avatar belka-ew avatar boarders avatar chessai avatar chshersh avatar galenhuntington avatar gbwey avatar goolord avatar gromakovsky avatar jacobstanley avatar kanwren avatar lucazulian avatar nobrakal avatar parsonsmatt avatar solomon-b avatar spacekitteh avatar tek avatar vrom911 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.