[Chronik] Add -chronikperfstats flag to write performance stats into <datadir>/perf
Summary:
Collect performance stats for TxWriter, SpentByWriter, GroupUtxoWriter and GroupHistoryWriter, which are the biggest culprits regarding performance at the moment.
Add *Stats structs for each of them, but also *MemData structs, which allows later optimizations to store in-memory caches etc.
Bundle all of them in MemData, which can be mapped to StatsData to obtain just the stats.
After resync_indexer completed, write the collected data to perf/resync_stats.txt. In the future, we might add other kinds of files.
Test Plan: Resync indexer using -chronikperfstats, verify perf/resync_stats.txt is created.
Reviewers: Fabien, #bitcoin_abc
Reviewed By: Fabien, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D14397