本文整理汇总了C++中ACE_High_Res_Timer::start方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_High_Res_Timer::start方法的具体用法?C++ ACE_High_Res_Timer::start怎么用?C++ ACE_High_Res_Timer::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_High_Res_Timer
的用法示例。
在下文中一共展示了ACE_High_Res_Timer::start方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
Ping_Suspend_Resume_Test::svc ()
{
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test::svc (), entering"));
ACE_hthread_t thread_id;
ACE_Thread_Manager::instance ()->thr_self (thread_id);
ACE_DEBUG ((LM_DEBUG, "; thread ID is %u\n", thread_id));
#endif /* ACE_DEBUG_CST */
high_.ready ();
#if ACE_DEBUG_CST > 0
int priority, high_priority;
ACE_OS::thr_getprio (thread_id, priority);
ACE_OS::thr_getprio (high_.thread_id (), high_priority);
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test::svc (), priority is %d, "
", high thread priority is %d\n",
priority, high_priority));
#endif /* ACE_DEBUG_CST */
// For information: the cost of the just the loop itself below,
// without the suspend and resume calls, on a 166 MHz Ultrasparc
// is about 12.3 nanoseconds per iteration.
timer_.start ();
ACE_UINT32 i;
for (i = 0; i < iterations_; ++i)
{
#if ACE_DEBUG_CST > 0
if (i % (iterations_ >= 10 ? iterations_ / 10 : 1) == 0)
{
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test::svc (), iteration "
"%d, continue high-priority thread %u\n",
i, high_.thread_id ()));
}
#endif /* ACE_DEBUG_CST */
if (ACE_OS::thr_continue (high_.thread_id ()) != 0 &&
errno != EINVAL)
// EINVAL is OK: it just means that the thread needs to be joined.
{
ACE_ERROR ((LM_ERROR, "%p\n", "thr_continue"));
high_.done ();
return -1;
}
}
timer_.stop ();
timer_.elapsed_microseconds (elapsed_time_);
high_.done ();
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test::svc: told high priority "
"task to terminate\n"));
#endif /* ACE_DEBUG_CST */
// Resume the thread until thr_continue fails, indicating that it has
// finished.
for (i = 0; i < 10000 && ! ACE_OS::thr_continue (high_.thread_id ());
++i) /* null */;
// Don't count the one iteration that was used to allow the high-priority
// thread to terminate.
if (high_.iterations () < iterations_)
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test: high priority task "
"executed only %u iterations!\n",
high_.iterations ()));
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Ping_Suspend_Resume_Test::svc, finishing\n"));
#endif /* ACE_DEBUG_CST */
return 0;
}
示例2: defined
int
Yield_Test::svc ()
{
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Yield_Test::svc (), entering"));
ACE_hthread_t thread_id;
ACE_Thread_Manager::instance ()->thr_self (thread_id);
int priority;
ACE_OS::thr_getprio (thread_id, priority);
ACE_DEBUG ((LM_DEBUG, "; thread ID is %u, priority is %u\n", thread_id,
priority));
#endif /* ACE_DEBUG_CST */
#if defined (VXWORKS)
// Start the timer, if it hasn't already been started.
if (! started_)
{
// Double-check.
ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1);
if (! started_)
{
started_ = 1;
timer_.start ();
}
}
#endif /* VXWORKS */
for (ACE_UINT32 i = 0; i < iterations_; ++i)
{
#if ACE_DEBUG_CST > 0
if (i % (iterations_ >= 10 ? iterations_ / 10 : 1) == 0)
{
ACE_DEBUG ((LM_DEBUG, "Yield_Test::svc () [%u], iteration %u\n",
thread_id, i));
}
#endif /* ACE_DEBUG_CST */
ACE_OS::thr_yield ();
}
#if defined (VXWORKS)
// Stop the timer, if it hasn't already been started.
if (! stopped_)
{
// Maybe it would be better to read the clock before grabbing
// the mutex. Then, only apply the clock reading below, instead
// of reading the clock after grabbing the mutex.
// Double-check.
ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1);
if (! stopped_)
{
stopped_ = 1;
timer_.stop ();
timer_.elapsed_time (elapsed_time_); /* nanoseconds */
}
}
#else /* ! VXWORKS */
timer_barrier_.wait ();
#endif /* ! VXWORKS */
#if ACE_DEBUG_CST > 0
ACE_DEBUG ((LM_DEBUG, "Yield_Test::svc, finishing\n"));
#endif /* ACE_DEBUG_CST */
return 0;
}
示例3: big_time_test
void big_time_test (CORBA::ULong num_list_loops,
CORBA::ULong num_seq_loops,
CORBA::ULong num_string_loops,
bool use_long_str)
{
ACE_High_Res_Timer timer;
ACE_hrtime_t time;
Seq_Structs big_list;
big_list.seq.length(0);
CORBA::ULong big_len;
CORBA::ULong red_len;
CORBA::ULong sss_len;
CORBA::ULong str_len;
// start timing
timer.start();
for (CORBA::ULong list_idx = 0; list_idx < num_list_loops; ++list_idx)
{
big_len = big_list.seq.length();
big_list.seq.length(big_len + 1);
Biglist_Struct & list = big_list.seq[big_len];
for (CORBA::ULong seq_idx = 0; seq_idx < num_seq_loops; ++seq_idx)
{
red_len = list.red_seqs.length();
list.red_seqs.length(red_len + 1);
Sequence_Str_Sequences & sss = list.red_seqs[red_len];
sss_len = sss.seq_str_seq.length();
sss.seq_str_seq.length(sss_len + 1);
Str_Sequences & strs = sss.seq_str_seq[sss_len];
for (CORBA::ULong str_idx = 0; str_idx < num_string_loops; ++str_idx)
{
str_len = strs.second_str.length();
strs.second_str.length(str_len + 1);
strs.second_str[str_len] = use_long_str ? long_str : short_str;
str_len = list.strs.first_str.length();
list.strs.first_str.length(str_len + 1);
list.strs.first_str[str_len] = use_long_str ? long_str : short_str;
} // end of str loop
} // end of seq loop
} // end of list loop
// end timing
timer.stop();
timer.elapsed_time(time);
if (use_csv)
{
ACE_DEBUG((LM_INFO,
ACE_TEXT("3, %u, %u, %u, %s, %Q\n"),
num_list_loops,
num_string_loops,
num_seq_loops,
use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"),
time ));
}
else
{
ACE_DEBUG((LM_INFO,
ACE_TEXT("Big list test(%u, %u, %u, %s) = %Q ns\n"),
num_list_loops,
num_string_loops,
num_seq_loops,
use_long_str ? ACE_TEXT("long"): ACE_TEXT("short"),
time ));
}
}
示例4: run_domain_test
//.........这里部分代码省略.........
TEST_CHECK (! CORBA::is_nil (widened_topic.in ()));
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(! CORBA::is_nil (widened_topic.in ()))")
ACE_TEXT("\n")
));
ACE_ERROR((LM_ERROR,
"We expect to see an error message from delete_participant\n"));
ret = dpf->delete_participant(new_dp.in ());
TEST_CHECK (ret == ::DDS::RETCODE_PRECONDITION_NOT_MET);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(ret == ::DDS::RETCODE_PRECONDITION_NOT_MET)")
ACE_TEXT("\n")
));
// delete existent topic first time
ret = new_dp->delete_topic(found_topic.in ());
TEST_CHECK (ret == ::DDS::RETCODE_OK);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(ret == ::DDS::RETCODE_OK)")
ACE_TEXT("\n")
));
// delete existent topic second time
ret = new_dp->delete_topic(new_topic.in ());
TEST_CHECK (ret == ::DDS::RETCODE_OK);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(ret == ::DDS::RETCODE_OK)")
ACE_TEXT("\n")
));
// an extra delete existent topic
ACE_ERROR((LM_ERROR,
"We expect to see an error message from delete_topic\n"));
ret = new_dp->delete_topic(new_topic.in ());
TEST_CHECK (ret == ::DDS::RETCODE_ERROR);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(ret == ::DDS::RETCODE_ERROR)")
ACE_TEXT("\n")
));
// Look up the topicdescription after the topic is deleted will
// return nil.
found_topicdescription
= new_dp->lookup_topicdescription(MY_TOPIC);
TEST_CHECK (CORBA::is_nil(found_topicdescription.in ()));
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(CORBA::is_nil(found_topicdescription.in ()))")
ACE_TEXT("\n")
));
// find a non-existent topic - return nil
ACE_High_Res_Timer timer;
ACE_Time_Value elapsedTime(0, 0);
timer.start ();
found_topic = new_dp->find_topic(OTHER_TOPIC, timeout);
timer.stop();
timer.elapsed_time(elapsedTime);
ACE_Time_Value tenMillis (0, 10000);
elapsedTime += tenMillis;
// some systems can be short by up to 10 milliseconds
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(CORBA::is_nil(found_topic.in ()) && elapsedTime.msec() >= find_topic_timeout.msec())")
ACE_TEXT("\n")
));
// delete the existent participant
ret = dpf->delete_participant(new_dp.in ());
TEST_CHECK (ret == ::DDS::RETCODE_OK);
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(ret == ::DDS::RETCODE_OK)")
ACE_TEXT("\n")
));
// lookup the participant after it's deleted - return nil
looked_dp = dpf->lookup_participant(MY_DOMAIN);
TEST_CHECK (CORBA::is_nil(looked_dp.in ()));
ACE_DEBUG((LM_DEBUG,
ACE_TEXT("(%P|%t) run_domain_test: ")
ACE_TEXT("(CORBA::is_nil(looked_dp.in ()))")
ACE_TEXT("\n")
));
return 0;
}
示例5: user_time
int
ACE_TMAIN (int argc_in,
ACE_TCHAR* argv_in[])
{
RPG_TRACE (ACE_TEXT ("::main"));
// *PROCESS PROFILE*
ACE_Profile_Timer process_profile;
// start profile timer...
process_profile.start ();
// step1: initialize
// // *PORTABILITY*: on Windows, init ACE...
//#if defined (ACE_WIN32) || defined (ACE_WIN64)
// if (ACE::init () == -1)
// {
// ACE_DEBUG ((LM_ERROR,
// ACE_TEXT ("failed to ACE::init(): \"%m\", aborting\n")));
// return EXIT_FAILURE;
// } // end IF
//#endif
// step1 init/validate configuration
// step1a: process commandline arguments
std::string configuration_path =
RPG_Common_File_Tools::getConfigurationDataDirectory (ACE_TEXT_ALWAYS_CHAR (BASEDIR),
true);
#if defined (DEBUG_DEBUGGER)
configuration_path = Common_File_Tools::getWorkingDirectory ();
#endif // #ifdef DEBUG_DEBUGGER
std::string configuration_file = configuration_path;
configuration_file += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#if defined (DEBUG_DEBUGGER)
configuration_file += ACE_TEXT_ALWAYS_CHAR ("protocol");
configuration_file += ACE_DIRECTORY_SEPARATOR_CHAR_A;
#endif
configuration_file += ACE_TEXT_ALWAYS_CHAR (IRC_CLIENT_CNF_DEF_INI_FILE);
bool debug_parser = false;
bool log_to_file = false;
bool trace_information = false;
bool print_version_and_exit = false;
unsigned int num_thread_pool_threads = IRC_CLIENT_DEF_NUM_TP_THREADS;
if (!do_processArguments (argc_in,
argv_in,
configuration_file,
debug_parser,
log_to_file,
trace_information,
print_version_and_exit,
num_thread_pool_threads))
{
// make 'em learn...
do_printUsage (ACE::basename (argv_in[0]));
// // *PORTABILITY*: on Windows, fini ACE...
//#if defined (ACE_WIN32) || defined (ACE_WIN64)
// if (ACE::fini () == -1)
// ACE_DEBUG ((LM_ERROR,
// ACE_TEXT ("failed to ACE::fini(): \"%m\", continuing\n")));
//#endif
return EXIT_FAILURE;
} // end IF
// validate argument(s)
if (!Common_File_Tools::isReadable (configuration_file))
{
// make 'em learn...
do_printUsage (ACE::basename (argv_in[0]));
// // *PORTABILITY*: on Windows, fini ACE...
//#if defined (ACE_WIN32) || defined (ACE_WIN64)
// if (ACE::fini () == -1)
// ACE_DEBUG ((LM_ERROR,
// ACE_TEXT ("failed to ACE::fini(): \"%m\", continuing\n")));
//#endif
return EXIT_FAILURE;
} // end IF
// initialize logging and/or tracing
std::string log_file;
if (log_to_file)
log_file = RPG_Common_File_Tools::getLogFilename (ACE::basename (argv_in[0]));
if (!Common_Tools::initializeLogging (ACE::basename (argv_in[0]), // program name
log_file, // logfile
false, // log to syslog ?
false, // trace messages ?
trace_information, // debug messages ?
NULL)) // logger
{
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("failed to Common_Tools::initializeLogging(), aborting\n")));
// // *PORTABILITY*: on Windows, need to fini ACE...
//#if defined (ACE_WIN32) || defined (ACE_WIN64)
// if (ACE::fini () == -1)
//.........这里部分代码省略.........
示例6: octetSeq
int
Client::svc (void)
{
try
{
Octet_Seq octetSeq(SIZE_BLOCK);
Char_Seq charSeq(SIZE_BLOCK);
ACE_High_Res_Timer timer;
ACE_OS::printf("Start sending %d Msgs...\n",this->niterations_);
charSeq.length(SIZE_BLOCK);
octetSeq.length(SIZE_BLOCK);
// This sets up the connector, so that we do not incur
// the overhead on the first call in the loop.
server_->sendCharSeq (charSeq);
timer.start ();
ACE_UINT32 client_count = 0;
for (ACE_UINT32 i = 0; i < this->niterations_; ++i)
{
client_count++;
server_->sendCharSeq (charSeq);
//server_->sendOctetSeq (octetSeq);
//ACE_DEBUG ((LM_DEBUG, "."));
}
timer.stop ();
ACE_Time_Value measured;
timer.elapsed_time (measured);
//ACE_DEBUG ((LM_DEBUG, "...finished\n"));
time_t dur = measured.sec () * 1000000 + measured.usec ();
if (dur == 0 || this->niterations_ == 0)
ACE_DEBUG ((LM_DEBUG, "Time not measurable, calculation skipped\n"));
else
{
ACE_DEBUG ((LM_DEBUG,
"Time for %u Msgs: %u usec\n",
this->niterations_,
dur));
ACE_DEBUG ((LM_DEBUG, "Time for 1 Msg: %u usec, %u calls/sec\n",
dur / this->niterations_,
1000000 / (dur / this->niterations_)));
}
for (int c = 0; c < 10; ++c)
server_->shutdown ();
}
catch (const CORBA::Exception& ex)
{
ex._tao_print_exception ("MT_Client: exception raised");
}
return 0;
}
示例7: defined
//.........这里部分代码省略.........
false, // trace messages ?
trace_information, // debug messages ?
NULL)) // logger
{
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("failed to Common_Tools::initializeLogging(), aborting\n")));
// *PORTABILITY*: on Windows, need to fini ACE...
#if defined (ACE_WIN32) || defined (ACE_WIN64)
if (ACE::fini () == -1)
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("failed to ACE::fini(): \"%m\", continuing\n")));
#endif
return EXIT_FAILURE;
} // end IF
// step4: handle specific program modes
if (print_version_and_exit)
{
do_printVersion (ACE::basename (argv_in[0]));
// *PORTABILITY*: on Windows, need to fini ACE...
#if defined (ACE_WIN32) || defined (ACE_WIN64)
if (ACE::fini () == -1)
ACE_DEBUG ((LM_ERROR,
ACE_TEXT ("failed to ACE::fini(): \"%m\", continuing\n")));
#endif
return EXIT_SUCCESS;
} // end IF
ACE_High_Res_Timer timer;
timer.start ();
// step5: do work
RPG_Dice_Rolls_t combinations;
do_work (value_range,
combinations);
timer.stop ();
// step6: print results
// header line
std::cout << ACE_TEXT ("results ")
<< RPG_Dice_Common_Tools::rangeToString (value_range)
<< ACE_TEXT (": ")
<< std::endl;
std::cout << std::setw (80)
<< std::setfill (ACE_TEXT_ALWAYS_CHAR ('-'))
<< ACE_TEXT ("")
<< std::setfill (ACE_TEXT_ALWAYS_CHAR (' '))
<< std::endl;
bool perfect_match = true;
int index = 1;
RPG_Dice_ValueRange range;
for (RPG_Dice_RollsIterator_t iterator = combinations.begin ();
iterator != combinations.end ();
iterator++, index++)
{
perfect_match = true;
RPG_Dice::rollToRange (*iterator, range);
if ((range.begin != value_range.begin) || (range.end != value_range.end))
{
// not a perfect match...