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.List
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Ord
|
import Data.Ord
|
||||||
|
import Data.HashSet (size, fromList)
|
||||||
|
import Data.Text (pack)
|
||||||
import Data.Time.Calendar
|
import Data.Time.Calendar
|
||||||
import System.Console.CmdArgs.Explicit
|
import System.Console.CmdArgs.Explicit
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
@ -63,7 +65,7 @@ showLedgerStats l today span =
|
|||||||
,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)
|
,("Transactions", printf "%d (%0.1f per day)" tnum txnrate)
|
||||||
,("Transactions last 30 days", printf "%d (%0.1f per day)" tnum30 txnrate30)
|
,("Transactions last 30 days", printf "%d (%0.1f per day)" tnum30 txnrate30)
|
||||||
,("Transactions last 7 days", printf "%d (%0.1f per day)" tnum7 txnrate7)
|
,("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)
|
,("Accounts", printf "%d (depth %d)" acctnum acctdepth)
|
||||||
,("Commodities", printf "%s (%s)" (show $ length cs) (intercalate ", " cs))
|
,("Commodities", printf "%s (%s)" (show $ length cs) (intercalate ", " cs))
|
||||||
-- Transactions this month : %(monthtxns)s (last month in the same period: %(lastmonthtxns)s)
|
-- Transactions this month : %(monthtxns)s (last month in the same period: %(lastmonthtxns)s)
|
||||||
|
|||||||
@ -74,6 +74,7 @@ library
|
|||||||
,base-compat >= 0.8.1
|
,base-compat >= 0.8.1
|
||||||
-- ,cabal-file-th
|
-- ,cabal-file-th
|
||||||
,containers
|
,containers
|
||||||
|
,unordered-containers
|
||||||
,cmdargs >= 0.10 && < 0.11
|
,cmdargs >= 0.10 && < 0.11
|
||||||
,csv
|
,csv
|
||||||
-- ,data-pprint >= 0.2.1 && < 0.3
|
-- ,data-pprint >= 0.2.1 && < 0.3
|
||||||
@ -128,6 +129,7 @@ executable hledger
|
|||||||
,base >= 4.3 && < 5
|
,base >= 4.3 && < 5
|
||||||
,base-compat >= 0.8.1
|
,base-compat >= 0.8.1
|
||||||
,containers
|
,containers
|
||||||
|
,unordered-containers
|
||||||
,cmdargs >= 0.10 && < 0.11
|
,cmdargs >= 0.10 && < 0.11
|
||||||
,csv
|
,csv
|
||||||
-- ,data-pprint >= 0.2.1 && < 0.3
|
-- ,data-pprint >= 0.2.1 && < 0.3
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user