diff --git a/hledger/Hledger/Cli/Utils.hs b/hledger/Hledger/Cli/Utils.hs index aaabfd528..f3e19ab89 100644 --- a/hledger/Hledger/Cli/Utils.hs +++ b/hledger/Hledger/Cli/Utils.hs @@ -51,6 +51,7 @@ import Text.Printf import Text.Regex.TDFA ((=~)) import System.Time (ClockTime(TOD)) +import System.TimeIt import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) import Hledger.Cli.CliOptions @@ -302,4 +303,27 @@ backupNumber f g = case g =~ ("^" ++ f ++ "\\.([0-9]+)$") of tests_Cli_Utils = tests "Utils" [ + tests "journalApplyValue" [ + + -- Print the time required to convert one of the sample journals' amounts to value. + -- Pretty clunky, but working. + test "time" $ do + ej <- io $ readJournalFile definputopts "examples/3000x1000x10.journal" + case ej of + Left e -> crash $ T.pack e + Right j -> do + (t,_) <- io $ timeItT $ do + -- Enable -V, and ensure the valuation date is later than + -- all prices for consistent timing. + let ropts = defreportopts{ + value_=True, + period_=PeriodTo $ parsedate "3000-01-01" + } + j' <- journalApplyValue ropts j + sum (journalAmounts j') `seq` return () + io $ printf "[%.3fs] " t + ok + + ] + ] diff --git a/hledger/hledger.cabal b/hledger/hledger.cabal index 83999261c..e38101bcb 100644 --- a/hledger/hledger.cabal +++ b/hledger/hledger.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: c25c2177f7c03b76b14aa9fa36b0cb9aba95bb836c183de3361616e41aed526a +-- hash: 3beb53c0c1f2c478c50a7c50e122085de41f983fcec16b3c14c058e2e79b19e1 name: hledger version: 1.14.99 @@ -174,6 +174,7 @@ library , temporary , text >=0.11 , time >=1.5 + , timeit , transformers , unordered-containers , utf8-string >=0.3.5 @@ -223,6 +224,7 @@ executable hledger , temporary , text >=0.11 , time >=1.5 + , timeit , transformers , unordered-containers , utf8-string >=0.3.5 @@ -277,6 +279,7 @@ test-suite test , test-framework-hunit , text >=0.11 , time >=1.5 + , timeit , transformers , unordered-containers , utf8-string >=0.3.5 diff --git a/hledger/package.yaml b/hledger/package.yaml index a7b2a68e9..56e0b0288 100644 --- a/hledger/package.yaml +++ b/hledger/package.yaml @@ -134,6 +134,7 @@ dependencies: - temporary - text >=0.11 - time >=1.5 +- timeit - transformers - unordered-containers - utf8-string >=0.3.5 @@ -215,4 +216,3 @@ benchmarks: - hledger - criterion - html - - timeit