123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #ifndef CNSTREAM_FRAMEWORK_CORE_INCLUDE_PROFILER_MODULE_PROFILER_HPP_
- #define CNSTREAM_FRAMEWORK_CORE_INCLUDE_PROFILER_MODULE_PROFILER_HPP_
- #include <memory>
- #include <string>
- #include <unordered_map>
- #include "cnstream_common.hpp"
- #include "cnstream_config.hpp"
- #include "profiler/process_profiler.hpp"
- #include "profiler/profile.hpp"
- #include "profiler/trace.hpp"
- namespace cnstream {
- static constexpr char kPROCESS_PROFILER_NAME[] = "PROCESS";
- static constexpr char kINPUT_PROFILER_NAME[] = "INPUT_QUEUE";
- class PipelineTracer;
- class ModuleProfiler : private NonCopyable {
- public:
-
- explicit ModuleProfiler(const ProfilerConfig& config,
- const std::string& module_name,
- PipelineTracer* tracer);
-
- bool RegisterProcessName(const std::string& process_name);
-
- bool RecordProcessStart(const std::string& process_name, const RecordKey& key);
-
- bool RecordProcessEnd(const std::string& process_name, const RecordKey& key);
-
- void OnStreamEos(const std::string& stream_name);
-
- std::string GetName() const;
-
- ModuleProfile GetProfile();
-
- ModuleProfile GetProfile(const ModuleTrace& trace);
- private:
-
- ProcessProfiler* GetProcessProfiler(const std::string& process_name);
- private:
- ProfilerConfig config_;
- std::string module_name_ = "";
- PipelineTracer* tracer_ = nullptr;
- std::unordered_map<std::string, std::unique_ptr<ProcessProfiler>> process_profilers_;
- };
- inline std::string ModuleProfiler::GetName() const {
- return module_name_;
- }
- }
- #endif
|