diff --git a/examples/ascii.journal b/examples/ascii.journal index d2d3a3e25..48d601e3e 100644 --- a/examples/ascii.journal +++ b/examples/ascii.journal @@ -1,12 +1,15 @@ -2015-01-01 transaction 1 - 1 1 - 1:2 -1 +2018-01-01 transaction 1 + 1 1 A + 1:2 -1 A -2015-01-02 transaction 2 - 1:2:3 1 - 1:2:3:4 -1 +2018-01-02 transaction 2 + 1:2:3 1 A + 1:2:3:4 -1 A -2015-01-03 transaction 3 - 1:2:3:4:5 1 - 1 -1 +2018-01-03 transaction 3 + 1:2:3:4:5 1 A + 1 -1 A +P 2018-01-01 A 0.70 B +P 2018-01-02 A 0.71 B +P 2018-01-03 A 0.72 B diff --git a/examples/chinese.journal b/examples/chinese.journal index 685a3fa62..f0850b4bb 100644 --- a/examples/chinese.journal +++ b/examples/chinese.journal @@ -1,12 +1,15 @@ -2014-01-01 transaction 1 - 㐀 1 - 㐀:㐁 -1 +2018-01-01 transaction 1 + 㐀 1 A + 㐀:㐁 -1 A -2014-01-02 transaction 2 - 㐀:㐁:㐂 1 - 㐀:㐁:㐂:㐃 -1 +2018-01-02 transaction 2 + 㐀:㐁:㐂 1 A + 㐀:㐁:㐂:㐃 -1 A -2014-01-03 transaction 3 - 㐀:㐁:㐂:㐃:㐄 1 - 㐀 -1 +2018-01-03 transaction 3 + 㐀:㐁:㐂:㐃:㐄 1 A + 㐀 -1 A +P 2018-01-01 A 0.70 B +P 2018-01-02 A 0.71 B +P 2018-01-03 A 0.72 B diff --git a/tools/generatejournal.hs b/tools/generatejournal.hs index a1e4be5d4..1844f454b 100755 --- a/tools/generatejournal.hs +++ b/tools/generatejournal.hs @@ -2,11 +2,12 @@ {- generatejournal.hs NUMTXNS NUMACCTS ACCTDEPTH [--chinese|--mixed] -Outputs a dummy journal file with the specified number of -transactions, number of accounts, and account tree depth. By default -it uses only ascii characters, with --chinese it uses wide chinese -characters, or with --mixed it uses both. These files are used for -testing, benchmarking, profiling, etc. +This generates synthetic journal data for benchmarking & profiling. +It prints a dummy journal on stdout, with NUMTXNS transactions, one +per day, using NUMACCTS account names with depths up to ACCTDEPTH. +It will also contain NUMACCTS P records, one per day. +By default it uses only ascii characters, with --chinese it uses wide +chinese characters, or with --mixed it uses both. -} module Main @@ -30,15 +31,20 @@ main = do let dates = iterate (addDays 1) d let accts = pair $ cycle $ take numaccts $ uniqueAccountNames opts acctdepth mapM_ (\(n,d,(a,b)) -> putStr $ showtxn n d a b) $ take numtxns $ zip3 [1..] dates accts + let rates = [0.70, 0.71 .. 1.3] + mapM_ (\(d,rate) -> putStr $ showmarketprice d rate) $ take numtxns $ zip dates (cycle $ rates ++ init (tail (reverse rates))) return () showtxn :: Int -> Day -> String -> String -> String showtxn txnno date acct1 acct2 = - printf "%s transaction %d\n %-40s %2d\n %-40s %2d\n\n" d txnno acct1 amt acct2 (-amt) + printf "%s transaction %d\n %-40s %2d A\n %-40s %2d A\n\n" d txnno acct1 amt acct2 (-amt) where d = show date amt = 1::Int +showmarketprice :: Day -> Double -> String +showmarketprice date rate = printf "P %s A %.2f B\n" (show date) rate + uniqueAccountNames :: [String] -> Int -> [String] uniqueAccountNames opts depth = mkacctnames uniquenames