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


C++ Stopwatch::getElapsed方法代码示例

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


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

示例1: main

int main(int argc, char** argv)
{
    verbose = getenv("PEGASUS_TEST_VERBOSE") ? true : false;

    Stopwatch sw;

    sw.start();

    System::sleep(5);

    sw.stop();

    double elapsed = sw.getElapsed();

    if(verbose)
    {
        sw.printElapsed();
    }

    PEGASUS_TEST_ASSERT((elapsed >= 4.5) && (elapsed <= 5.5));

    cout << argv[0] << " +++++ passed all tests" << endl;

    return 0;
}
开发者ID:rdobson,项目名称:openpegasus,代码行数:25,代码来源:TestStopwatch.cpp

示例2: _executeTests

ThreadReturnType PEGASUS_THREAD_CDECL _executeTests(void *parm)
{
    Thread *my_thread = (Thread *)parm;
    AutoPtr<T_Parms> parms((T_Parms *)my_thread->get_parm());
    CIMClient* client = parms->client;
    Uint32 indicationSendCount = parms->indicationSendCount;
    Uint32 id = parms->uniqueID;
    char id_[4];
    memset(id_,0x00,sizeof(id_));
    sprintf(id_,"%u",id);
    String uniqueID = "_";
    uniqueID.append(id_);

    try
    {
        Stopwatch elapsedTime;

        elapsedTime.start();
        try
        {
            _sendTestIndication (client, CIMName ("SendTestIndicationTrap"),
                                 indicationSendCount);
        }
        catch (Exception & e)
        {
            cerr << "----- sendTestIndication failed: " << e.getMessage () <<
                 endl;
            exit (-1);
        }
        elapsedTime.stop();
        _testEnd(uniqueID, elapsedTime.getElapsed());
    }
    catch(Exception  & e)
    {
        cout << e.getMessage() << endl;
    }

    return ThreadReturnType(0);
}
开发者ID:xenserver,项目名称:openpegasus,代码行数:39,代码来源:testSnmpHandler.cpp

示例3: main


//.........这里部分代码省略.........
                {
                    client.connect(host, portNumber, opts.user, opts.password);
                }
#else
                client.connect(host, portNumber, opts.user, opts.password);
#endif
            }
        }
    }    
    catch(Exception &e)
    {
        cerr << "Pegasus Exception: " << e.getMessage() <<
              " Trying to connect to " << opts.location << endl;
        exit(1);
    }

    // Register for Client statistics.
    ClientStatistics statistics = ClientStatistics();
    client.registerClientOpPerformanceDataHandler(statistics);

    if (opts.delay != 0)
    {
        // This was a test because of some delay caused problems.
        Threads::sleep(opts.delay * 1000);
    }

    // If the timeout is not zero, set the timeout for this connection.
    if (opts.connectionTimeout != 0)
    {
        client.setTimeout(opts.connectionTimeout * 1000);
    }

    // Save the total connect time.
    double totalConnectTime = opts.elapsedTime.getElapsed();

    double totalTime = 0;
    Uint32 repeatCount = opts.repeat;
    double maxTime = 0;
    double minTime = 10000000;

    Uint64 serverTotalTime = 0;
    Uint64 maxServerTime = 0;
    Uint64 minServerTime = 10000000;

    Uint64 rtTotalTime = 0;
    Uint64 maxRtTime = 0;
    Uint64 minRtTime = 10000000;

    // Process the input command within a try block.
    try
    {
        // Loop to repeat the command a number of times.
        do
        {
            // or exit with error through default of case logic
            switch(CommandTable[cmdIndex].ID_Command)
                {
                case ID_EnumerateInstanceNames :
                    if (!_getClassNameInput(argc, argv, opts, true))
                        exit(1);
                    enumerateInstanceNames(client, opts);
                    break;

                case ID_EnumerateAllInstanceNames :
                    if (!_getClassNameInput(argc, argv, opts, false))
                        exit(1);
开发者ID:host1812,项目名称:scx_plugin_public,代码行数:67,代码来源:CIMCLICommand.cpp

示例4: main


//.........这里部分代码省略.........
        {
            cout << "Start Try Block" << endl;
          try
          {
             cout << "Set Stopwatch" << endl;

             Stopwatch elapsedTime;

             cout << "Create client" << endl;
             CIMClient client;
             client.setTimeout(60 * 1000);
             cout << "Client created" << endl;

                     //
                     //  Get host and port number from connection list entry
                     //
                     Uint32 index = connectionList[i].find (':');
                     String host = connectionList[i].subString (0, index);
                     Uint32 portNumber = 0;
                     if (index != PEG_NOT_FOUND)
                     {
                         String portStr = connectionList[i].subString
                             (index + 1, connectionList[i].size ());
                         sscanf (portStr.getCString (), "%u", &portNumber);
                     }

                     if (useSSL)
             {

                        //
                        // Get environment variables:
                        //
                        const char* pegasusHome = getenv("PEGASUS_HOME");

                        String certpath = FileSystem::getAbsolutePath(
                            pegasusHome, PEGASUS_SSLCLIENT_CERTIFICATEFILE);

            String randFile;
#ifdef PEGASUS_SSL_RANDOMFILE
            randFile = FileSystem::getAbsolutePath(
                            pegasusHome, PEGASUS_SSLCLIENT_RANDOMFILE);
#endif

                        SSLContext sslcontext(certpath,verifyServerCertificate, randFile);

            if (om.isTrue("local"))
            {
                 cout << "Using local SSL connection mechanism " << endl;
                     client.connectLocal();
            }
            else
            {
                            cout << "connecting to " << connectionList[i] << " using SSL" << endl;
                            client.connect (host, portNumber, sslcontext,
                                            userName, password);
                        }
              }
                  else
              {
            if (om.isTrue("local"))
            {
                 cout << "Using local connection mechanism " << endl;
                     client.connectLocal();
            }
            else
            {
              cout << "Connecting to " << connectionList[i] << endl;
                            client.connect (host, portNumber,
                                            userName, password);
            }
              }
              cout << "Client Connected" << endl;

              testStart("Test NameSpace Operations - Relative Name");
              elapsedTime.reset();
              elapsedTime.start();
              TestNamespaceHierarchy1(client, activeTest, verboseTest);
              elapsedTime.stop();
              testEnd(elapsedTime.getElapsed());

              testStart("Test NameSpace Operations - Absolute Name");
              elapsedTime.reset();
              elapsedTime.start();
              TestNamespaceHierarchy2(client, activeTest, verboseTest);
              elapsedTime.stop();
              testEnd(elapsedTime.getElapsed());

              client.disconnect();
          }
          catch(Exception& e)
          {
               PEGASUS_STD(cerr) << "Error: " << e.getMessage() <<
                 PEGASUS_STD(endl);
               exit(1);
          }
        }
    }
    PEGASUS_STD(cout) << "+++++ "<< argv[0] << " Terminated Normally" << PEGASUS_STD(endl);
    return 0;
}
开发者ID:ncultra,项目名称:Pegasus-2.5,代码行数:101,代码来源:DeleteNamespace.cpp


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