Replace O(n log n) re-sorting of all prices on every valuation date with O(log n) indexed lookups. By pre-building sorted price indexes once at startup using O(n log n) time, we avoid redundant work during reports. This significantly improves performance for --value=end,COMM with daily reports over long periods and large price databases. Implementation: - PriceIndex maps commodity pairs to a Map from date to effective price, enabling O(log n) temporal lookups via M.lookupLE. - DefaultValuationIndex provides efficient resolution of destination commodities using the same temporal logic. - makePriceGraph is updated to consume these indexes. Signed-off-by: Oleg Bulatov <oleg@bulatov.me> |
||
|---|---|---|
| .. | ||
| Data | ||
| Read | ||
| Reports | ||
| Utils | ||
| Write | ||
| Data.hs | ||
| Query.hs | ||
| Read.hs | ||
| Reports.hs | ||
| Utils.hs | ||