1 #include "Task_Stats.h"
2 #include "ace/Log_Msg.h"
4 #if !defined (__ACE_INLINE__)
5 #include "Task_Stats.inl"
6 #endif /* __ACE_INLINE__ */
8 Base_Time::Base_Time (void)
10 base_time_
= ACE_OS::gethrtime ();
13 Task_Stats::Task_Stats (void)
21 exec_time_min_at_ (0),
29 Task_Stats::~Task_Stats (void)
31 delete[] this->thr_run_time_
;
32 delete[] this->thr_count_
;
36 Task_Stats::init (size_t max_samples
)
38 max_samples_
= max_samples
;
39 ACE_NEW_RETURN (this->thr_run_time_
, ACE_UINT32
[this->max_samples_
], -1);
40 ACE_NEW_RETURN (this->thr_count_
, int[this->max_samples_
], -1);
45 Task_Stats::base_time (ACE_hrtime_t time
)
51 Task_Stats::end_time (ACE_hrtime_t time
)
57 Task_Stats::dump_samples (const ACE_TCHAR
*file_name
, const ACE_TCHAR
*msg
)
59 FILE* output_file
= ACE_OS::fopen (file_name
, "w");
64 "%s cannot be opened\n",
68 // first dump what the caller has to say.
69 ACE_OS::fprintf (output_file
, "%s\n", ACE_TEXT_ALWAYS_CHAR (msg
));
71 // next, compose and dump what we want to say.
76 // dump the samples recorded.
77 for (size_t i
= 0; i
< this->samples_count_
; ++i
)
79 x
= this->thr_run_time_
[i
];
80 val_1
= ACE_CU64_TO_CU32 (x
);
81 val_2
= this->thr_count_
[i
];
82 ACE_OS::fprintf (output_file
, "%u \t %d\n",val_1
,val_2
);
85 ACE_OS::fclose (output_file
);
88 "Samples are ready to be viewed\n"));