/* * include/framework/scheduling/statistics.h * * Copyright (C) 2023 Douglas B. Rumbaugh * * Distributed under the Modified BSD License. * */ #pragma once #include #include #include #include #include #include #include namespace de { class SchedulerStatistics { private: enum class EventType { QUEUED, SCHEDULED, STARTED, FINISHED }; struct Event { size_t id; EventType type; }; struct JobInfo { size_t id; size_t size; size_t type; }; public: SchedulerStatistics() = default; ~SchedulerStatistics() = default; void job_queued(size_t id, size_t type, size_t size) { auto time = std::chrono::high_resolution_clock::now(); } void job_scheduled(size_t id) { std::unique_lock lk(m_mutex); } void job_begin(size_t id) { } void job_complete(size_t id) { } /* FIXME: This is just a temporary approach */ void log_time_data(size_t length, size_t type) { assert(type == 1 || type == 2); if (type == 1) { m_type_1_cnt.fetch_add(1); m_type_1_total_time.fetch_add(length); } else { m_type_2_cnt.fetch_add(1); m_type_2_total_time.fetch_add(length); } } void print_statistics() { fprintf(stdout, "Query Count: %ld\tQuery Avg. Latency: %ld\n", m_type_1_cnt.load(), m_type_1_total_time.load() / m_type_1_cnt.load()); fprintf(stdout, "Reconstruction Count: %ld\tReconstruction Avg. Latency: %ld\n", m_type_2_cnt.load(), m_type_2_total_time.load() / m_type_2_cnt.load()); } private: std::mutex m_mutex; std::unordered_map m_jobs; std::vector m_event_log; std::atomic m_type_1_cnt; std::atomic m_type_1_total_time; std::atomic m_type_2_cnt; std::atomic m_type_2_total_time; }; }