Slightly higher (with small files) and lower (with large files) maximum residency, and slightly quicker for all. hledger -f data/100x100x10.journal stats <<ghc: 42858472 bytes, 84 GCs, 193712/269608 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.015 elapsed), 0.016 MUT (0.042 elapsed), 0.011 GC (0.119 elapsed) :ghc>> <<ghc: 42891776 bytes, 84 GCs, 190816/260920 avg/max bytes residency (3 samples), 2M in use, 0.000 INIT (0.004 elapsed), 0.017 MUT (0.025 elapsed), 0.010 GC (0.015 elapsed) :ghc>> hledger -f data/1000x1000x10.journal stats <<ghc: 349575240 bytes, 681 GCs, 1396425/4091680 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.137 MUT (0.146 elapsed), 0.050 GC (0.057 elapsed) :ghc>> <<ghc: 349927568 bytes, 681 GCs, 1397825/4097248 avg/max bytes residency (7 samples), 11M in use, 0.000 INIT (0.000 elapsed), 0.126 MUT (0.133 elapsed), 0.050 GC (0.057 elapsed) :ghc>> hledger -f data/10000x1000x10.journal stats <<ghc: 3424029496 bytes, 6658 GCs, 11403141/41077288 avg/max bytes residency (11 samples), 111M in use, 0.000 INIT (0.000 elapsed), 1.278 MUT (1.310 elapsed), 0.493 GC (0.546 elapsed) :ghc>> <<ghc: 3427418064 bytes, 6665 GCs, 11127869/37790168 avg/max bytes residency (11 samples), 109M in use, 0.000 INIT (0.001 elapsed), 1.212 MUT (1.229 elapsed), 0.466 GC (0.519 elapsed) :ghc>> hledger -f data/100000x1000x10.journal stats <<ghc: 34306546248 bytes, 66727 GCs, 77030638/414617944 avg/max bytes residency (14 samples), 1012M in use, 0.000 INIT (0.000 elapsed), 12.965 MUT (13.164 elapsed), 4.771 GC (5.447 elapsed) :ghc>> <<ghc: 34340246056 bytes, 66779 GCs, 76983178/416011480 avg/max bytes residency (14 samples), 1011M in use, 0.000 INIT (0.008 elapsed), 12.666 MUT (12.836 elapsed), 4.595 GC (5.175 elapsed) :ghc>>
		
			
				
	
	
		
			95 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Haskell
		
	
	
	
	
	
			
		
		
	
	
			95 lines
		
	
	
		
			3.5 KiB
		
	
	
	
		
			Haskell
		
	
	
	
	
	
{-# LANGUAGE OverloadedStrings, QuasiQuotes, RecordWildCards #-}
 | 
						|
-- | /journal handlers.
 | 
						|
 | 
						|
module Handler.JournalR where
 | 
						|
 | 
						|
-- import Data.Text (Text)
 | 
						|
import qualified Data.Text as T
 | 
						|
import Import
 | 
						|
 | 
						|
import Handler.AddForm
 | 
						|
import Handler.Common
 | 
						|
 | 
						|
import Hledger.Data
 | 
						|
import Hledger.Query
 | 
						|
import Hledger.Reports
 | 
						|
import Hledger.Utils
 | 
						|
import Hledger.Cli.CliOptions
 | 
						|
import Hledger.Web.WebOptions
 | 
						|
 | 
						|
-- | The formatted journal view, with sidebar.
 | 
						|
getJournalR :: Handler Html
 | 
						|
getJournalR = do
 | 
						|
  vd@VD{..} <- getViewData
 | 
						|
  let -- XXX like registerReportAsHtml
 | 
						|
      inacct = inAccount qopts
 | 
						|
      -- injournal = isNothing inacct
 | 
						|
      filtering = m /= Any
 | 
						|
      -- showlastcolumn = if injournal && not filtering then False else True
 | 
						|
      title = case inacct of
 | 
						|
                Nothing       -> "General Journal"++s2
 | 
						|
                Just (a,inclsubs) -> "Transactions in "++T.unpack a++s1++s2
 | 
						|
                                      where s1 = if inclsubs then "" else " (excluding subaccounts)"
 | 
						|
                where
 | 
						|
                  s2 = if filtering then ", filtered" else ""
 | 
						|
      maincontent = journalTransactionsReportAsHtml opts vd $ journalTransactionsReport (reportopts_ $ cliopts_ opts) j m
 | 
						|
  hledgerLayout vd "journal" [hamlet|
 | 
						|
       <h2#contenttitle>#{title}
 | 
						|
       <!-- p>Journal entries record movements of commodities between accounts. -->
 | 
						|
       <a#addformlink role="button" style="cursor:pointer; margin-top:1em;" data-toggle="modal" data-target="#addmodal" title="Add a new transaction to the journal" >Add a transaction
 | 
						|
       ^{maincontent}
 | 
						|
     |]
 | 
						|
 | 
						|
postJournalR :: Handler Html
 | 
						|
postJournalR = postAddForm
 | 
						|
 | 
						|
-- | Render a "TransactionsReport" as html for the formatted journal view.
 | 
						|
journalTransactionsReportAsHtml :: WebOpts -> ViewData -> TransactionsReport -> HtmlUrl AppRoute
 | 
						|
journalTransactionsReportAsHtml _ vd (_,items) = [hamlet|
 | 
						|
<table.transactionsreport>
 | 
						|
 <tr.headings>
 | 
						|
  <th.date style="text-align:left;">
 | 
						|
   Date
 | 
						|
   <span .glyphicon .glyphicon-chevron-up>
 | 
						|
  <th.description style="text-align:left;">Description
 | 
						|
  <th.account style="text-align:left;">Account
 | 
						|
  <th.amount style="text-align:right;">Amount
 | 
						|
 $forall i <- numberTransactionsReportItems items
 | 
						|
  ^{itemAsHtml vd i}
 | 
						|
 |]
 | 
						|
 where
 | 
						|
-- .#{datetransition}
 | 
						|
   itemAsHtml :: ViewData -> (Int, Bool, Bool, Bool, TransactionsReportItem) -> HtmlUrl AppRoute
 | 
						|
   itemAsHtml VD{..} (n, _, _, _, (torig, _, split, _, amt, _)) = [hamlet|
 | 
						|
<tbody ##{tindex torig}>
 | 
						|
  <tr .item.#{evenodd}.#{firstposting} style="vertical-align:top;" title="#{show torig}">
 | 
						|
   <td.date>#{date}
 | 
						|
   <td.description colspan=2>#{textElideRight 60 desc}
 | 
						|
   <td.amount style="text-align:right;">
 | 
						|
    $if showamt
 | 
						|
     \#{mixedAmountAsHtml amt}
 | 
						|
  $forall p' <- tpostings torig
 | 
						|
   <tr .item.#{evenodd}.posting title="#{show torig}">
 | 
						|
    <td.date>
 | 
						|
    <td.description>
 | 
						|
    <td.account>
 | 
						|
      
 | 
						|
     <a href="@?{acctlink (paccount p')}##{tindex torig}" title="#{paccount p'}">#{elideAccountName 40 $ paccount p'}
 | 
						|
    <td.amount style="text-align:right;">#{mixedAmountAsHtml $ pamount p'}
 | 
						|
  <tr.#{evenodd}>
 | 
						|
   <td> 
 | 
						|
   <td>
 | 
						|
   <td>
 | 
						|
   <td>
 | 
						|
|]
 | 
						|
     where
 | 
						|
       acctlink a = (RegisterR, [("q", T.pack $ accountQuery a)])
 | 
						|
       evenodd = if even n then "even" else "odd" :: String
 | 
						|
       -- datetransition | newm = "newmonth"
 | 
						|
       --                | newd = "newday"
 | 
						|
       --                | otherwise = "" :: String
 | 
						|
       (firstposting, date, desc) = (False, show $ tdate torig, tdescription torig)
 | 
						|
       -- acctquery = (here, [("q", T.pack $ accountQuery acct)])
 | 
						|
       showamt = not split || not (isZeroMixedAmount amt)
 | 
						|
 |