本文整理汇总了C++中Time::DiffUSecs方法的典型用法代码示例。如果您正苦于以下问题:C++ Time::DiffUSecs方法的具体用法?C++ Time::DiffUSecs怎么用?C++ Time::DiffUSecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time::DiffUSecs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LeaveFrame
bool CallStack::LeaveFrame(const std::string& name,
const Time& leaveTime,
long& usecs,
bool longUnwind)
{
bool success = false;
SLOG_FROM(LOG_DEFAULT, "CallStack::LeaveFrame",
"Leaving: " << name)
if ( stack.size() > 0 ) {
Frame& frame = stack.back();
// If its the correct frame pop it...
if ( frame.name == name ) {
// Update the node in the call graph
usecs = leaveTime.DiffUSecs(frame.startTime);
activeNode->AddCall(usecs);
// Remove the frame from the stack
stack.pop_back();
if ( !activeNode->IsRoot() ) {
activeNode = activeNode->Parent();
}
success = true;
} else {
if (longUnwind) {
success = true;
Frame* pframe = &frame;
bool found = false;
do
{
pframe = &stack.back();
found = (pframe->name == name);
success &= LeaveFrame(pframe->name,leaveTime,usecs,false);
} while (stack.size() > 0 && !found);
if (!found) {
success = false;
}
} else {
usecs = -1;
SLOG_FROM(LOG_ERROR, "CallStack::LeaveFrame",
"Failed to leave frame " << name << " does not match statck " << stack.back().name;)
}
}
} else {
示例2: DoTimedTest
void DoTimedTest(const std::string& name,
size_t n,
std::function<void(size_t count)> f)
{
Time start;
f(n);
Time stop;
long duration_us = stop.DiffUSecs(start);
long duration_ms = duration_us / 1000;
double rate = (n) / (1.0 * duration_ms);
double cost = 1000* duration_us / (1.0 * n);
if ( baseline_duration == 0 )
{
baseline_duration = duration_us;
cout << "| ";
cout << setw(50) << left << name;
cout << " | ";
cout << left << setw(22) << duration_ms;
cout << " | ";
cout << setw(14) << left << rate;
cout << " | ";
cout << setw(14) << left << cost;
cout << " |";
} else {
long durationRatio = (duration_us / baseline_duration);
cout << "| ";
cout << setw(50) << left << name;
cout << " | ";
std::stringstream buf;
buf << left << duration_ms << " (x" << durationRatio<< ")";
cout << setw(22) << buf.str();
cout << " | ";
cout << setw(14) << left << rate;
cout << " | ";
cout << setw(14) << left << cost;
cout << " |";
}
results.AddRow(std::string(name),duration_us+0);
cout << endl;
}
示例3: Run
int NodeUserApp::Run() {
exit = false;
while ( !exit) {
string name = application.ActiveNode()->Name();
string shortName = name.substr(0,name.find("("));
string cmd = term->GetLine("|" + shortName + "> ");
try {
Time start;
Execute(cmd);
Time stop;
stringstream s;
s << "\"" + cmd + "\" completed in ";
s << stop.DiffUSecs(start) /1000 << "ms" << endl;;
term->PutString(s.str());
} catch ( Commands::ExecutionError& e ) {
term->PutString(e.msg + "\n");
}
}
return 0;
}
示例4: main
int main(int argc, const char *argv[])
{
Terminal& term = Screen::Instance().MainTerminal();
/*
* Sanity check command line args
*/
if ( argc != 2 ) {
cout << "Usage: cgv <data file>" << endl;
return 1;
}
/*
* Build the call graph
*/
term.PutString("Building call graph...");
Time start;
data = new CallgrindNative(argv[1]);
Time end;
COUT ( "done ("<< end.DiffUSecs(start)/1000 << "ms)" << endl)
/*
* Initialise the actual application and load user configuration
*/
application = new NodeUserApp(data->RootNode(),nullptr);
application->CommandDispatcher().AddCommand("annotate",&PrintAnnotation);
if ( ENV::IsSet("CGV_CONFIG_FILE") ) {
string rcpath = ENV::GetEnvString("CGV_CONFIG_FILE");
COUT ("Loading " + rcpath + "...");
start.SetNow();
CommandFile rcfile(rcpath);
application->Execute(rcfile);
end.SetNow();
COUT ( "done (" << end.DiffUSecs(start)/1000 << "ms)" << endl);
} else {
// Check the unix home directory for a config file
string homercpath = OS::Join(ENV::GetEnvString("HOME"),".cgvrc");
if ( OS::Exists(homercpath) ) {
COUT ("Loading " + homercpath + "...");
start.SetNow();
CommandFile homerc(homercpath);
application->Execute(homerc);
end.SetNow();
COUT ( "done (" << end.DiffUSecs(start)/1000 << "ms)" << endl);
}
// Check the local directory for a config file
if ( OS::Exists(".cgvrc") ) {
COUT ("Loading ./.cgvrc ...");
start.SetNow();
CommandFile localrc(".cgvrc");
application->Execute(localrc);
end.SetNow();
COUT ( "done (" << end.DiffUSecs(start)/1000 << "ms)" << endl);
}
}
/*
* Run the application
*/
int ret = application->Run();
delete application;
delete data;
return ret;
}