Skip to content

Commit

Permalink
1504 trick run summary enhancement for memory used (#1545)
Browse files Browse the repository at this point in the history
* Added SIM RAM usage info to trick run summary.

* Fixed to use #if for determing which OS.

* Removed the system print out statement when MonitorHealthStatusTask is finished.

* Changed "M" to "MB" for RAM usage info on run summery.
  • Loading branch information
hchen99 authored Aug 24, 2023
1 parent 7337e3b commit cca7191
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,6 @@ public Void doInBackground() {
@Override
protected void finished() {
try {
System.out.println("Finished with health status socket channel");
if (healthStatusSocketChannel != null) {
healthStatusSocketChannel.close() ;
}
Expand Down
17 changes: 14 additions & 3 deletions trick_source/sim_services/Executive/Executive_shutdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdlib.h>
#include <fcntl.h>
#include <iomanip>
#include <iostream>
#include <sys/resource.h>

#include "trick/Executive.hh"
Expand Down Expand Up @@ -40,7 +41,8 @@ int Trick::Executive::shutdown() {
unsigned int ii;
int process_id = 0 ;
struct rusage cpu_usage_buf ;

double sim_mem;

SIM_MODE prev_mode = mode ;

/* Set mode to ExitMode. */
Expand Down Expand Up @@ -80,6 +82,13 @@ int Trick::Executive::shutdown() {

getrusage(RUSAGE_SELF, &cpu_usage_buf);
cpu_time = ((double) cpu_usage_buf.ru_utime.tv_sec) + ((double) cpu_usage_buf.ru_utime.tv_usec / 1000000.0);

/* Get memory usage in MB for the calling process. Note that ru_maxrss returns long value in bytes on Mac and kilobytes on Linux. */
#if __APPLE__
sim_mem = (double)cpu_usage_buf.ru_maxrss / (1024 * 1024);
#else
sim_mem = (double)cpu_usage_buf.ru_maxrss / 1024;
#endif

/* Calculate simulation elapsed sim time and actual cpu time */
sim_elapsed_time = get_sim_time() - sim_start;
Expand All @@ -101,9 +110,11 @@ int Trick::Executive::shutdown() {
" SIMULATION ELAPSED TIME: %12.3f\n"
" ACTUAL CPU TIME USED: %12.3f\n"
" SIMULATION / CPU TIME: %12.3f\n"
" INITIALIZATION CPU TIME: %12.3f\n" ,
" INITIALIZATION CPU TIME: %12.3f\n"
" SIMULATION RAM USAGE: %12.3fMB\n"
" (External program RAM usage not included!)\n",
process_id, except_file.c_str(), except_message.c_str() ,
sim_start , get_sim_time() , sim_elapsed_time , actual_cpu_time , sim_to_cpu , cpu_init ) ;
sim_start , get_sim_time() , sim_elapsed_time , actual_cpu_time , sim_to_cpu , cpu_init, sim_mem ) ;

/* Kill all threads. */
for (ii = 1; ii < threads.size() ; ii++) {
Expand Down

0 comments on commit cca7191

Please sign in to comment.