Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ProcessTimer.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * ZW, Zef Wolffs, Nikhef, zefwolffs@gmail.com
5 * PB, Patrick Bos, Netherlands eScience Center, p.bos@esciencecenter.nl
6 *
7 * Copyright (c) 2022, CERN
8 *
9 * Redistribution and use in source and binary forms,
10 * with or without modification, are permitted according to the terms
11 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
12 */
13
14#ifndef ROOT_ROOFIT_MultiProcess_ProcessTimer
15#define ROOT_ROOFIT_MultiProcess_ProcessTimer
16
17#include <chrono>
18#include <string>
19#include <sys/types.h> // pid_t
20#include <map>
21#include <list>
22#include <nlohmann/json.hpp>
24
25namespace RooFit {
26namespace MultiProcess {
27
29public:
30 // setup processtimer, initialize some variables
31 static void setup(pid_t proc, bool set_begin = true)
32 {
34 if (set_begin)
35 ProcessTimer::begin = std::chrono::steady_clock::now();
37 };
38
39 static pid_t get_process() { return ProcessTimer::process; };
40 static void set_process(pid_t proc) { ProcessTimer::process = proc; };
41
42 static std::list<std::chrono::time_point<std::chrono::steady_clock>> get_durations(std::string section_name);
43
44 static void start_timer(std::string section_name);
45 static void end_timer(std::string section_name);
46
47 static void print_durations(std::string to_print = "all");
48 static void print_timestamps();
49
50 static void write_file();
51
52 static void add_metadata(json data);
53
54 static void set_write_interval(int write_interval);
55
56private:
57 // Map of a list of timepoints, even timepoints are start times, uneven timepoints are end times
58 using duration_map_t = std::map<std::string, std::list<std::chrono::time_point<std::chrono::steady_clock>>>;
59
61 static std::chrono::time_point<std::chrono::steady_clock> begin;
62 static std::chrono::time_point<std::chrono::steady_clock> previous_write;
63 static pid_t process;
64 static json metadata;
65 static int write_interval;
66 static int times_written;
67};
68
69} // namespace MultiProcess
70} // namespace RooFit
71
72#endif // ROOT_ROOFIT_MultiProcess_ProcessTimer
nlohmann::json json
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Can be used to generate timings of multiple processes simultaneously and output logs.
static void setup(pid_t proc, bool set_begin=true)
static void add_metadata(json data)
static void set_write_interval(int write_interval)
static void print_durations(std::string to_print="all")
static std::chrono::time_point< std::chrono::steady_clock > begin
static std::list< std::chrono::time_point< std::chrono::steady_clock > > get_durations(std::string section_name)
static void set_process(pid_t proc)
static std::chrono::time_point< std::chrono::steady_clock > previous_write
static void start_timer(std::string section_name)
std::map< std::string, std::list< std::chrono::time_point< std::chrono::steady_clock > > > duration_map_t
static duration_map_t durations
static void end_timer(std::string section_name)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition Common.h:18
basic_json<> json