@@ -152,6 +152,28 @@ def _str_to_tick_direction(tick_direction_str):
152
152
return _tick_direction_map .get (tick_direction_str , TickDirection .OFF )
153
153
154
154
155
+ # A bit mask used to select a set of profilers to enable:
156
+ # SYSTEM = 1 << 0
157
+ # COUNTERS = 1 << 1
158
+ # EXECUTIONS = 1 << 2
159
+ # EXECUTION_STATS = 1 << 3
160
+ # PIPELINES = 1 << 4
161
+ # By default enable all profiling besides EXECUTIONS.
162
+ _profile_level_map = {
163
+ "off" : 0 ,
164
+ "on" : 0b11011 ,
165
+ "detailed" : 0b11111
166
+ }
167
+
168
+
169
+ def _args_to_profile_level (cls , args , config_interface ):
170
+ if args .value .isdigit ():
171
+ mask_val = int (args .value )
172
+ else :
173
+ mask_val = _profile_level_map .get (args .value , 0 )
174
+ return ProfilingMask (mask_val )
175
+
176
+
155
177
_iono_delay_model_map = {
156
178
"auto" : IonoDelayModel .AUTO ,
157
179
"off" : IonoDelayModel .OFF ,
@@ -434,6 +456,8 @@ def _str_to_socket_type(key):
434
456
'watchdog_enabled' : {'format' : WatchdogTimerEnabled , 'arg_parse' : _args_to_bool },
435
457
'user_device_id' : {'format' : UserDeviceID , 'arg_parse' : _args_to_id },
436
458
459
+ 'profiling_enabled' : {'format' : ProfilingMask , 'arg_parse' : _args_to_profile_level },
460
+
437
461
'uart1_baud' : {'format' : Uart1BaudConfig , 'arg_parse' : _args_to_int_gen ('baud_rate' )},
438
462
'uart2_baud' : {'format' : Uart2BaudConfig , 'arg_parse' : _args_to_int_gen ('baud_rate' )},
439
463
'uart1_diagnostics_enabled' : {'format' : Uart1DiagnosticMessagesEnabled , 'arg_parse' : _args_to_bool },
@@ -1418,6 +1442,12 @@ def main():
1418
1442
help = 'The scale factor to convert from wheel encoder ticks to distance '
1419
1443
'(in meters/tick).' )
1420
1444
1445
+ help = 'Configure system profiling support.'
1446
+ param_parser .add_parser ('profiling_enabled' , help = help , description = help )
1447
+ profiling_enabled_parser = apply_param_parser .add_parser ('profiling_enabled' , help = help , description = help )
1448
+ profiling_enabled_parser .add_argument ('value' , help = 'Sets which profiling features are enabled.' ,
1449
+ choices = _profile_level_map .keys ())
1450
+
1421
1451
# config_tool.py apply -- output interface/stream control
1422
1452
help = 'Configure the UART1 serial baud rate.'
1423
1453
param_parser .add_parser ('uart1_baud' , help = help , description = help )
0 commit comments