46 profileDirectory->
SetGuidance(
"Profiler controls.");
48 profileOutputDirectory =
new G4UIdirectory(
"/profiler/output/");
49 profileOutputDirectory->
SetGuidance(
"Control the output modes of the profiler.");
51#define CREATE_DIR(IDX, DIR, GUIDANCE) \
52 profileTypeDirs.at(IDX) = new G4UIdirectory(DIR); \
53 profileTypeDirs.at(IDX)->SetGuidance(GUIDANCE)
61#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE) \
62 profileEnableCmds.at(IDX).second = CMDLINE; \
63 profileEnableCmds.at(IDX).first = new G4UIcmdWithABool(CMD, this); \
64 profileEnableCmds.at(IDX).first->SetDefaultValue(DEFAULT); \
65 profileEnableCmds.at(IDX).first->SetGuidance(GUIDANCE); \
66 profileEnableCmds.at(IDX).first->AvailableForStates(G4State_PreInit, G4State_Idle)
70 "Record metrics for each G4Event");
72 "Record metrics for each G4Track");
74 "Record metrics for each G4Step");
76 "Record metrics for user specified profiling instances");
78#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE) \
79 profileCompCmds.at(IDX).second = CMDLINE; \
80 profileCompCmds.at(IDX).first = new G4UIcmdWithAString(CMD, this); \
81 profileCompCmds.at(IDX).first->SetDefaultValue(DEFAULTS); \
82 profileCompCmds.at(IDX).first->SetGuidance(GUIDANCE); \
83 profileCompCmds.at(IDX).first->AvailableForStates(G4State_PreInit, G4State_Idle)
85 G4String comps =
"wall_clock, cpu_clock, cpu_util, peak_rss";
88 "Measurment types to record for each G4Run (see `timemory-avail -s`)");
90 "Measurment types to record for each G4Event (see `timemory-avail -s`)");
92 "Measurment types to record for each G4Track (see `timemory-avail -s`)");
94 "Measurment types to record for each G4Step (see `timemory-avail -s`)");
96 "Measurment types to record for user specified profiling "
97 "instances (see `timemory-avail -s`)");
99#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE) \
100 profileGeneralCmds.push_back({new G4UIcmdWithABool(CMD, this), CMDLINE}); \
101 profileGeneralCmds.back().first->SetDefaultValue(DEFAULT); \
102 profileGeneralCmds.back().first->SetGuidance(GUIDANCE); \
103 profileGeneralCmds.back().first->AvailableForStates(G4State_PreInit, G4State_Idle)
106 "Enabled Dart output (CTest/CDash data tracking)");
107 SET_OUTPUT_CMD(
"/profiler/output/json",
"--json",
true,
"Enabled JSON output");
108 SET_OUTPUT_CMD(
"/profiler/output/text",
"--text",
true,
"Enabled text output");
109 SET_OUTPUT_CMD(
"/profiler/output/cout",
"--cout",
false,
"Enabled output to console");
110 SET_OUTPUT_CMD(
"/profiler/output/plot",
"--plot",
false,
"Enabled plotting JSON output");
113 "Display the results as a call-stack hierarchy.");
114 SET_OUTPUT_CMD(
"/profiler/flat",
"--flat",
false,
"Display the results as a flat call-stack");
116 "Do not merge duplicate entries at the same call-stack "
117 "position. May be combined with tree or flat profiles.");
119 "Display the results for each individual thread (default: aggregation)");
121 "Display the results for each individual G4event (default: aggregation)");
128 delete profileDirectory;
129 delete profileOutputDirectory;
130 for (
auto& itr : profileTypeDirs) {
133 for (
auto& itr : profileEnableCmds) {
136 for (
auto& itr : profileGeneralCmds) {
139 for (
auto& itr : profileCompCmds) {
157 std::vector<std::string> command_line = {
"G4ProfilerMessenger"};
159 for (
auto& itr : profileGeneralCmds) {
162 command_line.push_back(itr.second.c_str());
163 command_line.push_back(value);
168 for (
auto& itr : profileCompCmds) {
171 command_line.push_back(itr.second);
172#if defined(GEANT4_USE_TIMEMORY)
173 for (
auto vitr : tim::delimit(value,
", ;"))
174 command_line.push_back(vitr);
180 if (command_line.size() > 1) {
#define SET_ENABLED_CMD(IDX, CMD, CMDLINE, DEFAULT, GUIDANCE)
#define SET_COMPONENTS_CMD(IDX, CMD, CMDLINE, DEFAULTS, GUIDANCE)
#define SET_OUTPUT_CMD(CMD, CMDLINE, DEFAULT, GUIDANCE)
#define CREATE_DIR(IDX, DIR, GUIDANCE)
~G4ProfilerMessenger() override
void SetNewValue(G4UIcommand *, G4String) override
static void Configure(const std::vector< std::string > &args)
static void SetEnabled(size_t v, bool val)
static G4bool GetNewBoolValue(const char *paramString)
void SetGuidance(const char *aGuidance)