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_
, time_t[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 // There's nothing to dump if this object was never initialized
60 if (this->thr_run_time_
== 0 || this->thr_count_
== 0)
63 FILE* output_file
= ACE_OS::fopen (file_name
, "w");
68 "%s cannot be opened\n",
72 // first dump what the caller has to say.
73 ACE_OS::fprintf (output_file
, "%s\n", ACE_TEXT_ALWAYS_CHAR (msg
));
75 // next, compose and dump what we want to say.
80 x
= this->thr_run_time_
[0];// scale_factor;
81 val_1
= ACE_CU64_TO_CU32 (x
);
83 ACE_OS::fprintf (output_file
, "%u \t %d\n",val_1
,thr_count_
[0]);
85 // dump the samples recorded.
86 for (size_t i
= 1; i
!= this->samples_count_
; ++i
)
88 x
= this->thr_run_time_
[i
];
89 val_1
= ACE_CU64_TO_CU32 (x
);
90 val_2
= this->thr_count_
[i
];
91 ACE_OS::fprintf (output_file
, "%u \t %d\n",val_1
,val_2
);
94 ACE_OS::fclose (output_file
);
97 "Samples are ready to view\n"));
100 ACE_SINGLETON_TEMPLATE_INSTANTIATE(ACE_Singleton
, Task_Stats
, TAO_SYNCH_MUTEX
);