summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-20 20:52:22 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-05-20 20:52:22 +0000
commitcb0d5cc591a9d68cfe0197fab8cd75b5c8c998c1 (patch)
tree7213f0a211d7d94637a21f5e1306ae4c9bfa011f
parentd016dbb25181e489ddf458bfa5870bb783b959fa (diff)
downloadATCD-cb0d5cc591a9d68cfe0197fab8cd75b5c8c998c1.tar.gz
use ACE_Stats to calculate standard deviations
-rw-r--r--performance-tests/Misc/context_switch_time.cpp39
1 files changed, 23 insertions, 16 deletions
diff --git a/performance-tests/Misc/context_switch_time.cpp b/performance-tests/Misc/context_switch_time.cpp
index 00039f53542..6fb0dfdb0a6 100644
--- a/performance-tests/Misc/context_switch_time.cpp
+++ b/performance-tests/Misc/context_switch_time.cpp
@@ -49,12 +49,12 @@ static const char usage [] = "[-? |\n"
" [-n to spawn a new LWP with each thread\n"
"[<iterations>]]";
-#include "ace/Sched_Params.h"
-#include "ace/ACE.h"
#include "ace/Task.h"
-#include "ace/Synch.h"
+#include "ace/Sched_Params.h"
+#include "ace/Stats.h"
#include "ace/High_Res_Timer.h"
#include "ace/Get_Opt.h"
+#include "ace/Synch.h"
#if defined (ACE_HAS_THREADS)
@@ -698,6 +698,9 @@ main (int argc, char *argv [])
int forever = count == 0;
+ ACE_Stats context_switch_test_stats;
+ ACE_Stats yield_test_stats;
+
while (forever || count-- > 0)
{
// Check to see if thr_continue (), and therefore thr_suspend (),
@@ -715,35 +718,31 @@ main (int argc, char *argv [])
// Wait for all tasks to exit.
ACE_Thread_Manager::instance ()->wait ();
- // NOTE: the divisions by (ACE_UINT32) 1u below allow transparent
- // support of ACE_U_LongLongs.
-
if (ping_suspend_resume_test.elapsed_time () >
suspend_resume_test.elapsed_time ())
{
+ context_switch_test_stats.
+ sample (ping_suspend_resume_test.elapsed_time () -
+ suspend_resume_test.elapsed_time ());
+
ACE_DEBUG ((LM_INFO, "context switch time is (%.3f - %.3f)/2 = "
"%.3f microseconds\n",
(double) (ping_suspend_resume_test.elapsed_time () /
- (ACE_UINT32) 1u) /
- num_iterations,
+ num_iterations),
(double) (suspend_resume_test.elapsed_time () /
- (ACE_UINT32) 1u) /
- num_iterations,
+ num_iterations),
(double) ((ping_suspend_resume_test.elapsed_time () -
suspend_resume_test.elapsed_time ()) /
- (ACE_UINT32) 1u) /
- num_iterations / 2));
+ num_iterations / 2u)));
}
else
{
ACE_DEBUG ((LM_INFO, "ping suspend/resume time of %.3f usec was "
"less than suspend/resume time of %.3f\n",
(double) (ping_suspend_resume_test.elapsed_time () /
- (ACE_UINT32) 1u) /
- num_iterations,
+ num_iterations),
(double) (suspend_resume_test.elapsed_time () /
- (ACE_UINT32) 1u) /
- num_iterations));
+ num_iterations)));
}
}
@@ -752,6 +751,8 @@ main (int argc, char *argv [])
// Wait for all tasks to exit.
ACE_Thread_Manager::instance ()->wait ();
+ yield_test_stats.sample (yield_test.elapsed_time ());
+
// Try _really_ hard not to use floating point.
ACE_DEBUG ((LM_INFO, "context switch time from yield test is %u.%03u "
"microseconds\n",
@@ -762,6 +763,12 @@ main (int argc, char *argv [])
1000u / num_iterations / 2u));
}
+ ACE_OS::printf ("context_switch_test:\n");
+ context_switch_test_stats.print_summary (3, num_iterations * 2u);
+
+ ACE_OS::printf ("\nyield_test:\n");
+ yield_test_stats.print_summary (3, num_iterations * 2u);
+
return 0;
}
#else