summaryrefslogtreecommitdiffstats
path: root/include/framework/scheduling/Task.h
diff options
context:
space:
mode:
authorDouglas Rumbaugh <dbr4@psu.edu>2024-01-19 15:58:04 -0500
committerDouglas Rumbaugh <dbr4@psu.edu>2024-01-19 15:58:04 -0500
commit38693c342558628c75e0ab0d23c32a95a499ed8b (patch)
treef193ff1990ea7976a8ceb5d3bf69d677d3e8ee7d /include/framework/scheduling/Task.h
parent138c793b0a58577713d98c98bb140cf1d9c79bee (diff)
downloaddynamic-extension-38693c342558628c75e0ab0d23c32a95a499ed8b.tar.gz
Initial rough-out of internal statistics tracker
Need to figure out the best way to do the detailed tracking in a concurrent manner. I was thinking just an event log, with parsing routines for extracting statistics. But that'll be pretty slow.
Diffstat (limited to 'include/framework/scheduling/Task.h')
-rw-r--r--include/framework/scheduling/Task.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/include/framework/scheduling/Task.h b/include/framework/scheduling/Task.h
index 16f5e58..b14b229 100644
--- a/include/framework/scheduling/Task.h
+++ b/include/framework/scheduling/Task.h
@@ -10,9 +10,11 @@
#include <future>
#include <functional>
+#include <chrono>
#include "framework/util/Configuration.h"
#include "framework/scheduling/Epoch.h"
+#include "framework/scheduling/statistics.h"
namespace de {
@@ -35,17 +37,21 @@ struct QueryArgs {
typedef std::function<void(void*)> Job;
struct Task {
- Task(size_t size, size_t ts, Job job, void *args)
+ Task(size_t size, size_t ts, Job job, void *args, size_t type=0, SchedulerStatistics *stats=nullptr)
: m_job(job)
, m_size(size)
, m_timestamp(ts)
, m_args(args)
+ , m_type(type)
+ , m_stats(stats)
{}
Job m_job;
size_t m_size;
size_t m_timestamp;
void *m_args;
+ size_t m_type;
+ SchedulerStatistics *m_stats;
friend bool operator<(const Task &self, const Task &other) {
return self.m_timestamp < other.m_timestamp;
@@ -56,7 +62,22 @@ struct Task {
}
void operator()(size_t thrd_id) {
+ auto start = std::chrono::high_resolution_clock::now();
+ if (m_stats) {
+ m_stats->job_begin(m_timestamp);
+ }
+
m_job(m_args);
+
+ if (m_stats) {
+ m_stats->job_complete(m_timestamp);
+ }
+ auto stop = std::chrono::high_resolution_clock::now();
+
+ if (m_stats) {
+ auto time = std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start).count();
+ m_stats->log_time_data(time, m_type);
+ }
}
};