tf::TFProfObserver class

observer interface based on the built-in taskflow profiler format

A tf::TFProfObserver inherits tf::ObserverInterface and defines methods to dump the observed thread activities into a format that can be visualized through .

tf::Taskflow taskflow;
tf::Executor executor;

// insert tasks into taskflow
// ...
  
// create a custom observer
std::shared_ptr<tf::TFProfObserver> observer = executor.make_observer<tf::TFProfObserver>();

// run the taskflow
executor.run(taskflow).wait();

// dump the thread activities to Taskflow Profiler format.
observer->dump(std::cout);

We recommend using our python script to observe thread activities instead of the raw function call. The script will turn on environment variables needed for observing all executors in a taskflow program and dump the result to a valid, clean JSON file compatible with the format of .

Base classes

class ObserverInterface
The interface class for creating an executor observer.

Public functions

void dump(std::ostream& ostream) const
dumps the timelines into a format through an output stream
auto dump() const -> std::string
dumps the timelines into a JSON string
void clear()
clears the timeline data
auto num_tasks() const -> size_t
queries the number of tasks observed

Private functions

void set_up(size_t num_workers) final
constructor-like method to call when the executor observer is fully created
void on_entry(WorkerView w, TaskView task_view) final
method to call before a worker thread executes a closure
void on_exit(WorkerView w, TaskView task_view) final
method to call after a worker thread executed a closure

Function documentation

void tf::TFProfObserver::set_up(size_t num_workers) final private

constructor-like method to call when the executor observer is fully created

Parameters
num_workers the number of the worker threads in the executor

void tf::TFProfObserver::on_entry(WorkerView w, TaskView task_view) final private

method to call before a worker thread executes a closure

Parameters
w an immutable view of this worker thread
task_view a constant wrapper object to the task

void tf::TFProfObserver::on_exit(WorkerView w, TaskView task_view) final private

method to call after a worker thread executed a closure

Parameters
w an immutable view of this worker thread
task_view a constant wrapper object to the task