stats: fix O(n^2) performance, now much faster on large journals
This commit is contained in:
parent
745f2dd788
commit
e516aa6c3c
@ -13,6 +13,8 @@ where
|
||||
import Data.List
|
||||
import Data.Maybe
|
||||
import Data.Ord
|
||||
import Data.HashSet (size, fromList)
|
||||
import Data.Text (pack)
|
||||
import Data.Time.Calendar
|
||||
import System.Console.CmdArgs.Explicit
|
||||
import Text.Printf
|
||||
@ -63,7 +65,7 @@ showLedgerStats l today span =
|
||||
,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)
|
||||
,("Transactions last 30 days", printf "%d (%0.1f per day)" tnum30 txnrate30)
|
||||
,("Transactions last 7 days", printf "%d (%0.1f per day)" tnum7 txnrate7)
|
||||
,("Payees/descriptions", show $ length $ nub $ map tdescription ts)
|
||||
,("Payees/descriptions", show $ size $ fromList $ map (pack . tdescription) ts)
|
||||
,("Accounts", printf "%d (depth %d)" acctnum acctdepth)
|
||||
,("Commodities", printf "%s (%s)" (show $ length cs) (intercalate ", " cs))
|
||||
-- Transactions this month : %(monthtxns)s (last month in the same period: %(lastmonthtxns)s)
|
||||
|
||||
@ -74,6 +74,7 @@ library
|
||||
,base-compat >= 0.8.1
|
||||
-- ,cabal-file-th
|
||||
,containers
|
||||
,unordered-containers
|
||||
,cmdargs >= 0.10 && < 0.11
|
||||
,csv
|
||||
-- ,data-pprint >= 0.2.1 && < 0.3
|
||||
@ -128,6 +129,7 @@ executable hledger
|
||||
,base >= 4.3 && < 5
|
||||
,base-compat >= 0.8.1
|
||||
,containers
|
||||
,unordered-containers
|
||||
,cmdargs >= 0.10 && < 0.11
|
||||
,csv
|
||||
-- ,data-pprint >= 0.2.1 && < 0.3
|
||||
|
||||
Loading…
Reference in New Issue
Block a user