Exemple #1
0
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;
}