2018-08-20 16:28:40 +03:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
2014-09-11 00:07:53 +04:00
|
|
|
{-|
|
2010-05-20 03:08:53 +04:00
|
|
|
|
2010-07-13 10:30:06 +04:00
|
|
|
The Hledger.Data library allows parsing and querying of C++ ledger-style
|
|
|
|
journal files. It generally provides a compatible subset of C++ ledger's
|
2011-01-21 04:24:51 +03:00
|
|
|
functionality. This package re-exports all the Hledger.Data.* modules
|
|
|
|
(except UTF8, which requires an explicit import.)
|
2010-05-20 03:08:53 +04:00
|
|
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
module Hledger.Data (
|
|
|
|
module Hledger.Data.Account,
|
|
|
|
module Hledger.Data.AccountName,
|
|
|
|
module Hledger.Data.Amount,
|
|
|
|
module Hledger.Data.Commodity,
|
|
|
|
module Hledger.Data.Dates,
|
|
|
|
module Hledger.Data.Journal,
|
2019-12-17 04:15:24 +03:00
|
|
|
module Hledger.Data.Json,
|
2011-06-05 22:36:32 +04:00
|
|
|
module Hledger.Data.Ledger,
|
2016-07-29 20:27:30 +03:00
|
|
|
module Hledger.Data.Period,
|
2018-07-30 21:38:47 +03:00
|
|
|
module Hledger.Data.PeriodicTransaction,
|
2010-05-20 03:08:53 +04:00
|
|
|
module Hledger.Data.Posting,
|
2014-03-26 04:10:30 +04:00
|
|
|
module Hledger.Data.RawOptions,
|
2015-08-20 06:28:24 +03:00
|
|
|
module Hledger.Data.StringFormat,
|
2016-04-13 07:10:02 +03:00
|
|
|
module Hledger.Data.Timeclock,
|
2011-06-05 22:36:32 +04:00
|
|
|
module Hledger.Data.Transaction,
|
2018-07-30 21:38:47 +03:00
|
|
|
module Hledger.Data.TransactionModifier,
|
2010-05-20 03:08:53 +04:00
|
|
|
module Hledger.Data.Types,
|
2019-06-15 02:17:06 +03:00
|
|
|
module Hledger.Data.Valuation,
|
2018-09-06 23:08:26 +03:00
|
|
|
tests_Data
|
2010-05-20 03:08:53 +04:00
|
|
|
)
|
|
|
|
where
|
2011-05-28 08:11:44 +04:00
|
|
|
|
2010-05-20 03:08:53 +04:00
|
|
|
import Hledger.Data.Account
|
|
|
|
import Hledger.Data.AccountName
|
|
|
|
import Hledger.Data.Amount
|
|
|
|
import Hledger.Data.Commodity
|
|
|
|
import Hledger.Data.Dates
|
|
|
|
import Hledger.Data.Journal
|
2019-12-17 04:15:24 +03:00
|
|
|
import Hledger.Data.Json
|
2011-06-05 22:36:32 +04:00
|
|
|
import Hledger.Data.Ledger
|
2016-07-29 20:27:30 +03:00
|
|
|
import Hledger.Data.Period
|
2018-07-30 21:38:47 +03:00
|
|
|
import Hledger.Data.PeriodicTransaction
|
2010-05-20 03:08:53 +04:00
|
|
|
import Hledger.Data.Posting
|
2014-03-26 04:10:30 +04:00
|
|
|
import Hledger.Data.RawOptions
|
2015-08-20 06:28:24 +03:00
|
|
|
import Hledger.Data.StringFormat
|
2016-04-13 07:10:02 +03:00
|
|
|
import Hledger.Data.Timeclock
|
2011-06-05 22:36:32 +04:00
|
|
|
import Hledger.Data.Transaction
|
2018-07-30 21:38:47 +03:00
|
|
|
import Hledger.Data.TransactionModifier
|
lib: Change internal representation of MixedAmount to use a strict Map
instead of a list of Amounts. No longer export Mixed constructor, to
keep API clean (if you really need it, you can import it directly from
Hledger.Data.Types). We also ensure the JSON representation of
MixedAmount doesn't change: it is stored as a normalised list of
Amounts.
This commit improves performance. Here are some indicative results.
hledger reg -f examples/10000x1000x10.journal
- Maximum residency decreases from 65MB to 60MB (8% decrease)
- Total memory in use decreases from 178MiB to 157MiB (12% decrease)
hledger reg -f examples/10000x10000x10.journal
- Maximum residency decreases from 69MB to 60MB (13% decrease)
- Total memory in use decreases from 198MiB to 153MiB (23% decrease)
hledger bal -f examples/10000x1000x10.journal
- Total heap usage decreases from 6.4GB to 6.0GB (6% decrease)
- Total memory in use decreases from 178MiB to 153MiB (14% decrease)
hledger bal -f examples/10000x10000x10.journal
- Total heap usage decreases from 7.3GB to 6.9GB (5% decrease)
- Total memory in use decreases from 196MiB to 185MiB (5% decrease)
hledger bal -M -f examples/10000x1000x10.journal
- Total heap usage decreases from 16.8GB to 10.6GB (47% decrease)
- Total time decreases from 14.3s to 12.0s (16% decrease)
hledger bal -M -f examples/10000x10000x10.journal
- Total heap usage decreases from 108GB to 48GB (56% decrease)
- Total time decreases from 62s to 41s (33% decrease)
If you never directly use the constructor Mixed or pattern match against
it then you don't need to make any changes. If you do, then do the
following:
- If you really care about the individual Amounts and never normalise
your MixedAmount (for example, just storing `Mixed amts` and then
extracting `amts` as a pattern match, then use should switch to using
[Amount]. This should just involve removing the `Mixed` constructor.
- If you ever call `mixed`, `normaliseMixedAmount`, or do any sort of
amount arithmetic (+), (-), then you should replace the constructor
`Mixed` with the function `mixed`. To extract the list of Amounts, use
the function `amounts`.
- If you ever call `normaliseMixedAmountSquashPricesForDisplay`, you can
replace that with `mixedAmountStripPrices`. (N.B. this does something
slightly different from `normaliseMixedAmountSquashPricesForDisplay`,
but I don't think there's any use case for squashing prices and then
keeping the first of the squashed prices around. If you disagree let
me know.)
- Any remaining calls to `normaliseMixedAmount` can be removed, as that
is now the identity function.
2021-01-29 08:07:11 +03:00
|
|
|
import Hledger.Data.Types hiding (MixedAmountKey, Mixed)
|
2019-06-15 02:17:06 +03:00
|
|
|
import Hledger.Data.Valuation
|
2018-08-18 09:33:41 +03:00
|
|
|
import Hledger.Utils.Test
|
2010-05-20 03:08:53 +04:00
|
|
|
|
2018-09-06 23:08:26 +03:00
|
|
|
tests_Data = tests "Data" [
|
|
|
|
tests_AccountName
|
|
|
|
,tests_Amount
|
|
|
|
,tests_Journal
|
|
|
|
,tests_Ledger
|
|
|
|
,tests_Posting
|
2019-06-15 02:17:06 +03:00
|
|
|
,tests_Valuation
|
2018-09-06 23:08:26 +03:00
|
|
|
,tests_StringFormat
|
|
|
|
,tests_Timeclock
|
|
|
|
,tests_Transaction
|
2018-08-20 16:28:40 +03:00
|
|
|
]
|