lib: add a test for journalApplyValue that times itself (#999)
This test prints the time elapsed (before the OK message). Mainly to support current performance tuning (make ghcid-test-Hledger.Cli.Utils.journalApplyValue), but also for future reference.
This commit is contained in:
parent
168edb910e
commit
08d226aaf5
@ -51,6 +51,7 @@ import Text.Printf
|
|||||||
import Text.Regex.TDFA ((=~))
|
import Text.Regex.TDFA ((=~))
|
||||||
|
|
||||||
import System.Time (ClockTime(TOD))
|
import System.Time (ClockTime(TOD))
|
||||||
|
import System.TimeIt
|
||||||
import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)
|
import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)
|
||||||
|
|
||||||
import Hledger.Cli.CliOptions
|
import Hledger.Cli.CliOptions
|
||||||
@ -302,4 +303,27 @@ backupNumber f g = case g =~ ("^" ++ f ++ "\\.([0-9]+)$") of
|
|||||||
|
|
||||||
tests_Cli_Utils = tests "Utils" [
|
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
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,7 +4,7 @@ cabal-version: 1.12
|
|||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
--
|
--
|
||||||
-- hash: c25c2177f7c03b76b14aa9fa36b0cb9aba95bb836c183de3361616e41aed526a
|
-- hash: 3beb53c0c1f2c478c50a7c50e122085de41f983fcec16b3c14c058e2e79b19e1
|
||||||
|
|
||||||
name: hledger
|
name: hledger
|
||||||
version: 1.14.99
|
version: 1.14.99
|
||||||
@ -174,6 +174,7 @@ library
|
|||||||
, temporary
|
, temporary
|
||||||
, text >=0.11
|
, text >=0.11
|
||||||
, time >=1.5
|
, time >=1.5
|
||||||
|
, timeit
|
||||||
, transformers
|
, transformers
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, utf8-string >=0.3.5
|
, utf8-string >=0.3.5
|
||||||
@ -223,6 +224,7 @@ executable hledger
|
|||||||
, temporary
|
, temporary
|
||||||
, text >=0.11
|
, text >=0.11
|
||||||
, time >=1.5
|
, time >=1.5
|
||||||
|
, timeit
|
||||||
, transformers
|
, transformers
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, utf8-string >=0.3.5
|
, utf8-string >=0.3.5
|
||||||
@ -277,6 +279,7 @@ test-suite test
|
|||||||
, test-framework-hunit
|
, test-framework-hunit
|
||||||
, text >=0.11
|
, text >=0.11
|
||||||
, time >=1.5
|
, time >=1.5
|
||||||
|
, timeit
|
||||||
, transformers
|
, transformers
|
||||||
, unordered-containers
|
, unordered-containers
|
||||||
, utf8-string >=0.3.5
|
, utf8-string >=0.3.5
|
||||||
|
|||||||
@ -134,6 +134,7 @@ dependencies:
|
|||||||
- temporary
|
- temporary
|
||||||
- text >=0.11
|
- text >=0.11
|
||||||
- time >=1.5
|
- time >=1.5
|
||||||
|
- timeit
|
||||||
- transformers
|
- transformers
|
||||||
- unordered-containers
|
- unordered-containers
|
||||||
- utf8-string >=0.3.5
|
- utf8-string >=0.3.5
|
||||||
@ -215,4 +216,3 @@ benchmarks:
|
|||||||
- hledger
|
- hledger
|
||||||
- criterion
|
- criterion
|
||||||
- html
|
- html
|
||||||
- timeit
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user