#include <pakfire/string.h>
#include <pakfire/util.h>
+// How often to submit stats?
+#define PAKFIRE_STATS_WHEN_BUSY S_TO_US(15)
+#define PAKFIRE_STATS_WHEN_IDLE S_TO_US(60)
+
// It would be nice store the credentials cache in memory, but on Debian,
// cURL is compiled with Heimdal which is incompatible with the KRB5 in-memory cache.
// The on-disk format is however is compatible between two implementations.
// If we have any jobs running, we will submit our stats
// every five seconds, otherwise 30 seconds is enough.
- uint64_t next = (daemon->running_jobs > 0) ? 5000000 : 30000000;
+ uint64_t next = (daemon->running_jobs > 0) ? PAKFIRE_STATS_WHEN_BUSY : PAKFIRE_STATS_WHEN_IDLE;
// Reset the timer
r = sd_event_source_set_time_relative(daemon->stats_timer, next);
// Time
+// seconds to microseconds
+#define S_TO_MS(s) (s * 1000)
+#define S_TO_US(s) (s * 1000000)
+#define S_TO_NS(s) (s * 1000000000)
+
+#define MS_TO_S(s) (s / 1000)
+#define US_TO_S(s) (s / 1000000)
+#define NS_TO_S(s) (s / 1000000000)
+
static inline double pakfire_timespec_delta(struct timespec* t1, struct timespec* t2) {
// Compute delta in seconds
return (