]> git.tdb.fi Git - builder.git/blobdiff - source/lib/builder.cpp
Report timings of the build
[builder.git] / source / lib / builder.cpp
index c8c7bf81efbccb47726edef19c1ae11417184103..3379f2dcfebdea1e1f0d4533189d4480f71ba7ed 100644 (file)
@@ -5,6 +5,7 @@
 #include <msp/core/maputils.h>
 #include <msp/datafile/parser.h>
 #include <msp/fs/dir.h>
+#include <msp/fs/stat.h>
 #include <msp/fs/utils.h>
 #include <msp/io/buffered.h>
 #include <msp/io/file.h>
@@ -47,6 +48,9 @@ void Builder::load_plugins()
        using CreateFunc = Plugin *(Builder &);
 
        FS::Path plugins_dir = FS::get_sys_lib_dir();
+       if(!FS::exists(plugins_dir))
+               return;
+
        logger->log("files", "Traversing %s", plugins_dir);
        vector<LoadedPlugin> unordered_plugins;
        for(const string &f: list_filtered(plugins_dir, "\\.dlm$"))
@@ -278,6 +282,7 @@ void Builder::save_caches()
 int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
 {
        unsigned total = build_graph.count_rebuild_targets();
+       Time::TimeStamp start_time = Time::now();
 
        if(!total)
        {
@@ -289,6 +294,7 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
        vector<Task *> tasks;
 
        unsigned count = 0;
+       Time::TimeDelta sum_time;
 
        bool fail = false;
        bool finish = false;
@@ -346,6 +352,13 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
                        {
                                ++count;
 
+                               const vector<const FileTarget *> &targets = tasks[i]->get_targets();
+                               if(!targets.empty())
+                               {
+                                       sum_time += tasks[i]->get_duration();
+                                       get_logger().log("timings", "%s built in %s", targets.front()->get_name(), tasks[i]->get_duration());
+                               }
+
                                delete tasks[i];
                                tasks.erase(tasks.begin()+i);
                                if(status==Task::ERROR)
@@ -366,6 +379,9 @@ int Builder::build(unsigned jobs, bool dry_run, bool show_progress)
        else if(show_progress)
                get_logger().log("summary", "Build complete");
 
+       Time::TimeStamp end_time = Time::now();
+       get_logger().log("timings", "Build took %s, with a total %s spent on tasks", end_time-start_time, sum_time);
+
        return fail;
 }