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


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

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


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

示例1: generateRand_3

void generateRand_3(int array[], int arraySize)
{
    Stopwatch stopWatch;
    int i;
    for (i=0; i<arraySize; i++)      //fill array first
    {
        array[i] = i+1;
    }
    stopWatch.start();
    for (i=1; i<arraySize; i++)      //now randomly swap stuff
    {
        swap(array[i], array[ array[i] = (int)(rand()*rand() % arraySize) ]);
    }
    stopWatch.stop();
    displayStats(arraySize, stopWatch.user(), stopWatch.user()/arraySize);
}
开发者ID:RachelJMorris,项目名称:Code-Atrocities,代码行数:16,代码来源:main.cpp

示例2: generateRand_1

void generateRand_1(int array[], int arraySize)
{
    Stopwatch stopWatch;
    bool bad = false;       //a flag for checking to see if a certain number was already in another element.
    stopWatch.start();
    for (int i=0; i<arraySize; i++)
    {
        do
        {
            array[i] = (int)(rand()*rand() % arraySize);  //Assign a random value to array[i]
            bad = false;                        //set bad flag to false
            for (int j=0; j<i; j++)           //check each element up to current one
            {
                if ((int)array[i] == (int)array[j])       //if there is already one similar
                {
                    bad = true;                 //make bad flag true.
                }
            }
        } while ( bad );                        //keep assigning new numbers until it's not bad.
    }
    stopWatch.stop();
    displayStats(arraySize, stopWatch.user(), stopWatch.user()/(arraySize * arraySize * log10(arraySize)));
}
开发者ID:RachelJMorris,项目名称:Code-Atrocities,代码行数:23,代码来源:main.cpp

示例3: generateRand_2

void generateRand_2(int array[], int arraySize)
{
    Stopwatch stopWatch;
    int i;                          //for the loops
    bool used[arraySize];            //array to hold whether a number has been used
    for (i=0; i<arraySize; i++) { used[i] = false; }     //initialize array

    for (i=0; i<arraySize; i++)
    {
        array[i] = (int)(rand()*rand() % arraySize);               //Assign random value
        if ( i > 0 )
        {
            //Check to see if that number was already used
            while ( used[ array[i] ] == true )
            {
                array[i] = (int)(rand()*rand() % arraySize);
            }
        }
        used[ array[i] ] = true;
    }
    stopWatch.stop();
    displayStats(arraySize, stopWatch.user(), stopWatch.user()/(arraySize * log10(arraySize)));
}
开发者ID:RachelJMorris,项目名称:Code-Atrocities,代码行数:23,代码来源:main.cpp


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