]> git.ipfire.org Git - pakfire.git/commitdiff
execute: Log how much CPU time was spent
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 May 2021 13:35:37 +0000 (13:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 22 May 2021 13:35:37 +0000 (13:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/execute.c

index cb806fbd672f0ff2147671e1625f595e63f9282a..abae3e1dd9c69cd84c5631422ab4c5f64041c1b4 100644 (file)
@@ -577,6 +577,20 @@ PAKFIRE_EXPORT int pakfire_execute(Pakfire pakfire, const char* argv[], char* en
        if (r)
                goto ERROR;
 
+       struct pakfire_cgroup_cpustat cpustat;
+
+       // Fetch CPU usage stats
+       r = pakfire_cgroup_cpustat(pakfire, env.cgroup, &cpustat);
+       if (r) {
+               ERROR(pakfire, "Could not read CPU usage stats: %s\n", strerror(errno));
+               r = -1;
+               goto ERROR;
+       }
+
+       // Log CPU usage stats
+       DEBUG(pakfire, "cgroup %s used %.4fs of CPU time\n", env.cgroup,
+               (double)(cpustat.usage.tv_sec) + ((double)cpustat.usage.tv_usec / 1000000));
+
        // Return the exit code of the application
        r = exit;