mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 20:57:55 +00:00
More rusage info added to the end of the run summary output enhancement (#1645)
* Added additional resource usage info for sim run. * Fixed so voluntary context switches output uses corresponding ru_nvcsw instead of ru_nivcsw due to copy and paste error. * Removed added resource usage data for page faults and block operations due to inconsistency on different OS. * Updated to have voluntary and involuntary usage data for both initilization and run for sim shutdown run summary.
This commit is contained in:
parent
df5bdc3107
commit
2ac342cfc5
@ -123,6 +123,12 @@ namespace Trick {
|
||||
/** CPU usage time at cyclic sim process startup in kernal mode.\n */
|
||||
double kernal_cpu_start; /**< trick_io(**) trick_units(s) */
|
||||
|
||||
/** Voluntary context switche usage at executive initialization.\n */
|
||||
long v_context_switch_init; /**< trick_units(--) */
|
||||
|
||||
/** Involuntary context switche usage at executive initialization.\n */
|
||||
long iv_context_switch_init; /**< trick_units(--) */
|
||||
|
||||
/** Simulation control mode.\n */
|
||||
SIM_MODE mode; /**< trick_io(*o) trick_units(--) */
|
||||
|
||||
|
@ -60,6 +60,10 @@ int Trick::Executive::init() {
|
||||
cpu_time = ((double) cpu_usage_buf.ru_stime.tv_sec) + ((double) cpu_usage_buf.ru_stime.tv_usec / 1000000.0);
|
||||
kernal_cpu_init = cpu_time - kernal_cpu_start;
|
||||
|
||||
/* Record both voluntary and involuntary context switches usage for initialization */
|
||||
v_context_switch_init = cpu_usage_buf.ru_nvcsw;
|
||||
iv_context_switch_init = cpu_usage_buf.ru_nivcsw;
|
||||
|
||||
initialization_complete = true ;
|
||||
|
||||
/* Print as much error information avaiable for all exception and exit. */
|
||||
|
@ -42,7 +42,8 @@ int Trick::Executive::shutdown() {
|
||||
int process_id = 0 ;
|
||||
struct rusage cpu_usage_buf ;
|
||||
double sim_mem;
|
||||
|
||||
long v_context_switch_run, iv_context_switch_run;
|
||||
|
||||
SIM_MODE prev_mode = mode ;
|
||||
|
||||
/* Set mode to ExitMode. */
|
||||
@ -104,26 +105,36 @@ int Trick::Executive::shutdown() {
|
||||
sim_to_cpu = sim_elapsed_time / (user_cpu_time + kernal_cpu_time);
|
||||
}
|
||||
|
||||
/* Calculate voluntary and involuntary context switch usage during run */
|
||||
v_context_switch_run = cpu_usage_buf.ru_nvcsw - v_context_switch_init ;
|
||||
iv_context_switch_run = cpu_usage_buf.ru_nivcsw - iv_context_switch_init ;
|
||||
|
||||
/* Print a shutdown message. */
|
||||
message_publish(MSG_NORMAL , "\n"
|
||||
"SIMULATION TERMINATED IN\n"
|
||||
" PROCESS: %d\n"
|
||||
" ROUTINE: %s\n"
|
||||
" DIAGNOSTIC: %s\n\n"
|
||||
" SIMULATION START TIME: %12.3f\n"
|
||||
" SIMULATION STOP TIME: %12.3f\n"
|
||||
" SIMULATION ELAPSED TIME: %12.3f\n"
|
||||
" USER CPU TIME USED: %12.3f\n"
|
||||
" SYSTEM CPU TIME USED: %12.3f\n"
|
||||
" SIMULATION / CPU TIME: %12.3f\n"
|
||||
" INITIALIZATION USER CPU TIME: %12.3f\n"
|
||||
" INITIALIZATION SYSTEM CPU TIME: %12.3f\n"
|
||||
" SIMULATION RAM USAGE: %12.3fMB\n"
|
||||
" (External program RAM usage not included!)\n",
|
||||
" SIMULATION START TIME: %12.3f\n"
|
||||
" SIMULATION STOP TIME: %12.3f\n"
|
||||
" SIMULATION ELAPSED TIME: %12.3f\n"
|
||||
" USER CPU TIME USED: %12.3f\n"
|
||||
" SYSTEM CPU TIME USED: %12.3f\n"
|
||||
" SIMULATION / CPU TIME: %12.3f\n"
|
||||
" INITIALIZATION USER CPU TIME: %12.3f\n"
|
||||
" INITIALIZATION SYSTEM CPU TIME: %12.3f\n"
|
||||
" SIMULATION RAM USAGE: %12.3fMB\n"
|
||||
" (External program RAM usage not included!)\n"
|
||||
" VOLUNTARY CONTEXT SWITCHES (INIT): %12ld\n"
|
||||
"INVOLUNTARY CONTEXT SWITCHES (INIT): %12ld\n"
|
||||
" VOLUNTARY CONTEXT SWITCHES (RUN): %12ld\n"
|
||||
" INVOLUNTARY CONTEXT SWITCHES (RUN): %12ld\n\n",
|
||||
process_id, except_file.c_str(), except_message.c_str(),
|
||||
sim_start, get_sim_time(), sim_elapsed_time,
|
||||
user_cpu_time, kernal_cpu_time, sim_to_cpu,
|
||||
user_cpu_init, kernal_cpu_init, sim_mem) ;
|
||||
user_cpu_init, kernal_cpu_init, sim_mem,
|
||||
v_context_switch_init, iv_context_switch_init,
|
||||
v_context_switch_run, iv_context_switch_run) ;
|
||||
|
||||
/* Kill all threads. */
|
||||
for (ii = 1; ii < threads.size() ; ii++) {
|
||||
|
Loading…
Reference in New Issue
Block a user