当前位置: 首页>>代码示例>>C++>>正文


C++ World::GetCommands方法代码示例

本文整理汇总了C++中World::GetCommands方法的典型用法代码示例。如果您正苦于以下问题:C++ World::GetCommands方法的具体用法?C++ World::GetCommands怎么用?C++ World::GetCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在World的用法示例。


在下文中一共展示了World::GetCommands方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Execute

BOOL CMDSstatus::Execute(const std::string &verb, Player* mobile,std::vector<std::string> &args,int subcmd)
{
    using std::setw;

    World* world = World::GetPtr();
    std::stringstream st;
    unsigned long long int updates = 0;
    unsigned long long int tu = 0; //total update time
    unsigned long long int ts = 0; //total sleep time.
    unsigned long long int commands = 0; //commands executed.
    unsigned long long int commandTime = 0; //average command time.
    struct rusage usage;

    st << std::setprecision(3);
    getrusage(RUSAGE_SELF, &usage);
//cpu usage
    st << "userspace cpu usage: " << TimevalToString(&(usage.ru_utime)) << "." << std::endl;
    st << "Kernel cpu usage: " << TimevalToString(&(usage.ru_stime)) << "." << std::endl;
//memory:
    st << "Max rss: " << usage.ru_maxrss << "KB (" << (usage.ru_maxrss/1024.0F) << "mb)." << std::endl;
    st << Repeat("-", 80) << std::endl;
//timing information
    updates = world->GetUpdates();
    tu = world->GetUpdateTime();
    ts = world->GetSleepTime();
    st << "Total updates: " << updates << std::endl;
    st << "Average work time: " << ((double)tu/(double)updates) / 1000.0F << "MS." << std::endl;
    st << "Average sleep time: " << ((double)ts / (double)updates) / 1000.0F << "MS." << std::endl;
    st << "Spent ~" << ((double)tu / (double)ts) * 100.0F  << "% time working." << std::endl;
    st << CalloutManager::GetInstance()->Profile() << std::endl;
    commands = world->GetCommands();
    commandTime = world->GetCommandTime();
    st << "Total commands executed (that succeeded): " << commands << std::endl;
    st << "Average command time: " << ((double)commandTime/commands)/1000 << " MS." << std::endl;

    mobile->Message(MSG_INFO, st.str());
    return true;
}
开发者ID:sorressean,项目名称:Aspen,代码行数:38,代码来源:com_wiz.cpp


注:本文中的World::GetCommands方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。