summaryrefslogtreecommitdiff
path: root/performance-tests/Synch-Benchmarks/synch_driver.cpp
diff options
context:
space:
mode:
authornanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-28 08:23:44 +0000
committernanbor <nanbor@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-06-28 08:23:44 +0000
commit03d7f82f98e0914ead0a425b94a39c1a1bed5c90 (patch)
tree76506afed47e75b463406c653b33e5815762482d /performance-tests/Synch-Benchmarks/synch_driver.cpp
parent9491864d4ce2ce40527d7a7ae5b1216c5c35cb40 (diff)
downloadATCD-03d7f82f98e0914ead0a425b94a39c1a1bed5c90.tar.gz
*** empty log message ***
Diffstat (limited to 'performance-tests/Synch-Benchmarks/synch_driver.cpp')
-rw-r--r--performance-tests/Synch-Benchmarks/synch_driver.cpp138
1 files changed, 16 insertions, 122 deletions
diff --git a/performance-tests/Synch-Benchmarks/synch_driver.cpp b/performance-tests/Synch-Benchmarks/synch_driver.cpp
index ccbb4674273..c180eef4fe6 100644
--- a/performance-tests/Synch-Benchmarks/synch_driver.cpp
+++ b/performance-tests/Synch-Benchmarks/synch_driver.cpp
@@ -7,151 +7,45 @@
#include "ace/Service_Repository.h"
#include "ace/Synch.h"
#include "Options.h"
-#include "Benchmark.h"
+#include "Benchmark_Performance.h"
#if defined (ACE_HAS_THREADS)
-
-class Benchmark_Test : public ACE_Service_Config
-{
-public:
- Benchmark_Test (void);
- int init (int argc, char **argv);
-
-private:
- void run_test (void);
-
- int n_lwps_;
- int orig_n_lwps_;
- ACE_Sig_Adapter done_;
-};
-
-Benchmark_Test::Benchmark_Test (void)
- : ACE_Service_Config (1), // Do not load default services
- n_lwps_ (0),
- orig_n_lwps_ (0),
- done_ (ACE_Sig_Handler_Ex (ACE_Reactor::end_event_loop))
-{
- ACE_Reactor::instance ()->register_handler (SIGINT, &this->done_);
-}
-
-void
-Benchmark_Test::run_test (void)
-{
- // Tell the threads that we are not finished.
- Benchmark::done (0);
-
- // Allow thread(s) to make progress.
- ACE_Thread_Manager::instance ()->resume_all ();
-
- ACE_Time_Value timeout (options.sleep_time ());
-
- ACE_DEBUG ((LM_DEBUG, "starting timer\n"));
- options.start_timer ();
-
- // Use Reactor as a timer (which can be interrupted by a signal).
- ACE_Reactor::run_event_loop (timeout);
-
- options.stop_timer ();
- ACE_DEBUG ((LM_DEBUG, "\nstopping timer\n"));
-
- // Stop thread(s) from making any further progress.
- ACE_Thread_Manager::instance ()->suspend_all ();
-
- // Tell the threads that we are finished.
- Benchmark::done (1);
-
- ACE_DEBUG ((LM_DEBUG, "------------------------------------------------------------------------\n"));
- ACE_DEBUG ((LM_DEBUG, "targ 0x%x (%s, %s, %s)\n"
- "n_lwps_orig = %d, n_lwps_set = %d, n_lwps_end = %d\n",
- options.t_flags (),
- (options.t_flags () & THR_DETACHED) ? "THR_DETACHED" : "Not Detached",
- (options.t_flags () & THR_BOUND) ? "THR_BOUND" : "Not Bound",
- (options.t_flags () & THR_NEW_LWP) ? "THR_NEW_LWP" : "No New_LWP",
- this->orig_n_lwps_, this->n_lwps_, ACE_Thread::getconcurrency ()));
-
- int count = options.count ();
- float rate = count / (float (options.sleep_time ()));
-
- ACE_DEBUG ((LM_DEBUG,
- "to count = %d\nrate = %.3f ops/sec, per operation = %.2f usec\n",
- count,
- rate,
- (1.0e6 / rate) / synch_count));
- options.print_results ();
-
- // Allow thread(s) to finish up.
- ACE_Thread_Manager::instance ()->resume_all ();
-
- // Wait for all the threads to exit.
- ACE_Thread_Manager::instance ()->wait ();
- options.init ();
-}
-
-// Initialize and run the benchmarks tests.
-
int
-Benchmark_Test::init (int argc, char **argv)
+main (int argc, char *argv[])
{
- options.parse_args (argc, argv);
-
- // Open the service configurator and process the directives in the
- // svc.conf file.
-
- if (this->open (argv[0]) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "ACE_Service_Config::open failed\n%a", 1), -1);
-
+ ACE_Service_Config::open (argc, argv);
ACE_Service_Repository_Iterator sri (*ACE_Service_Repository::instance ());
-
+
// Iteratively execute each service loaded in from the svc.conf
// file.
- for (const ACE_Service_Type *sr;
- sri.next (sr) != 0;
- sri.advance ())
+ for (const ACE_Service_Type *sr;
+ sri.next (sr) != 0; )
{
// This would greatly benefit from RTTI typesafe downcasting...
const ACE_Service_Type_Impl *type = sr->type ();
const void *obj = type->object ();
ACE_Service_Object *so = (ACE_Service_Object *) obj;
- Benchmark *bp = (Benchmark *) so;
-
- ACE_DEBUG ((LM_DEBUG, "\nstarting up %s\n", sr->name ()));
+ Benchmark_Base *bb = (Benchmark_Base *) so;
- this->orig_n_lwps_ = ACE_Thread::getconcurrency ();
- this->n_lwps_ = options.n_lwps ();
+ if (bb->benchmark_type () == Benchmark_Base::METHOD)
+ {
+ Benchmark_Method_Base *bm = (Benchmark_Method_Base *) bb;
- if (this->n_lwps_ > 0)
- ACE_Thread::setconcurrency (this->n_lwps_);
+ ACE_DEBUG ((LM_DEBUG, "\n\nExecuting %s\n", sr->name ()));
- // We should probably use a "barrier" here rather than
- // THR_SUSPENDED since many OS platforms lack the ability to
- // create suspended threads...
- if (ACE_Thread_Manager::instance ()->spawn_n
- (options.thr_count (), ACE_THR_FUNC (bp->svc_run),
- (void *) bp, options.t_flags () | THR_SUSPENDED) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n%a", "couldn't spawn threads", 1));
-
- this->run_test ();
+ bm->exec (&sri);
+ }
+ else
+ sri.advance ();
}
-
- return 0;
-}
-
-int
-main (int argc, char *argv[])
-{
- Benchmark_Test benchmark_tester;
-
- if (benchmark_tester.init (argc, argv) == -1)
- ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1));
-
return 0;
}
#else
int
main (int, char *[])
{
- ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_ERROR_RETURN ((LM_ERROR,
"This test requires the platform to have threads\n"), -1);
}
#endif /* ACE_HAS_THREADS */