summaryrefslogtreecommitdiff
path: root/main.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-04-27 10:09:21 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:32 -0400
commit4db6d4535f57413eff7ae5a0c9475ae9b4ec4fb4 (patch)
treede2416d7ee12cfeb2c08970d93623faf6007c844 /main.cc
parenta85bd282d7868cd1d7b7f166a2e8d2f13abfde13 (diff)
downloadfork-ledger-4db6d4535f57413eff7ae5a0c9475ae9b4ec4fb4.tar.gz
fork-ledger-4db6d4535f57413eff7ae5a0c9475ae9b4ec4fb4.tar.bz2
fork-ledger-4db6d4535f57413eff7ae5a0c9475ae9b4ec4fb4.zip
Beat the timing and tracing code into shape.
Diffstat (limited to 'main.cc')
-rw-r--r--main.cc31
1 files changed, 16 insertions, 15 deletions
diff --git a/main.cc b/main.cc
index c2cc2cf7..777b8086 100644
--- a/main.cc
+++ b/main.cc
@@ -42,9 +42,9 @@ static int read_and_report(report_t * report, int argc, char * argv[],
// Process the environment settings
- TRACE(1, "Processing options and environment settings");
-
+ TRACE_START(environment, 1, "Processed environment variables");
process_environment(const_cast<const char **>(envp), "LEDGER_", report);
+ TRACE_FINISH(environment, 1);
const char * p = std::getenv("HOME");
string home = p ? p : "";
@@ -68,7 +68,7 @@ static int read_and_report(report_t * report, int argc, char * argv[],
TRACE(1, "Main journal is " << session.data_file);
if (! session.use_cache)
- INFO("The binary cache mechanism will not be used");
+ INFO("Binary cache mechanism will not be used");
// Read the command word and create a command object based on it
@@ -168,9 +168,14 @@ static int read_and_report(report_t * report, int argc, char * argv[],
session.read_init();
- std::cout << "Reading journal ..." << std::endl;
+ INFO_START(journal, "Read journal file");
journal_t * journal = session.read_data(report->account);
- std::cout << "Generating report ..." << std::endl;
+ INFO_FINISH(journal);
+
+ TRACE_FINISH(entry_date, 2);
+ TRACE_FINISH(entry_details, 2);
+ TRACE_FINISH(entry_xacts, 2);
+ TRACE_FINISH(parsing_total, 2);
// Configure the output stream
@@ -323,16 +328,20 @@ static int read_and_report(report_t * report, int argc, char * argv[],
#endif
}
+ INFO_START(transforms, "Applied transforms");
report->apply_transforms(journal->document);
+ INFO_FINISH(transforms);
+ INFO_START(command, "Did user command '" << verb << "'");
value_t temp;
(*command)(temp, locals.get());
+ INFO_FINISH(command);
// Write out the binary cache, if need be
if (session.use_cache && session.cache_dirty &&
! session.cache_file.empty()) {
- TRACE_START(binary_cache, 1, "Writing journal file");
+ TRACE_START(binary_cache, 1, "Wrote binary journal file");
std::ofstream stream(session.cache_file.c_str());
#if 0
@@ -345,12 +354,8 @@ static int read_and_report(report_t * report, int argc, char * argv[],
#if defined(FREE_MEMORY)
// Cleanup memory -- if this is a beta or development build.
- TRACE_START(cleanup, 1, "Cleaning up allocated memory");
-
if (! report->output_file.empty())
delete out;
-
- TRACE_STOP(cleanup, 1);
#endif
// If the user specified a pager, wait for it to exit now
@@ -374,12 +379,8 @@ int main(int argc, char * argv[], char * envp[])
{
int status = 1;
-#if defined(FULL_DEBUG)
- ledger::verify_enabled = true;
-#endif
-
for (int i = 1; i < argc; i++)
- if (argv[i][0] == '-' && argv[i][1] == '-') {
+ if (argv[i][0] == '-') {
#if defined(VERIFY_ON)
if (std::strcmp(argv[i], "--verify") == 0)
ledger::verify_enabled = true;