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


C++ GoBoard::FirstBoardPoint方法代码示例

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


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

示例1: CheckPerformance

void GoBoardCheckPerformance::CheckPerformance(const GoBoard& board,
                                               ostream& out)
{
    const int NUM_REPETITIONS = 10000;
    int i;

    double startTime = SgTime::Get();
    int sum1 = 0;
    for (i = 0; i < NUM_REPETITIONS; ++i)
    {
        for (SgPoint p = 0; p < SG_MAXPOINT; ++p)
        {   if (board.IsEmpty(p))
                sum1 += p;
        }
    }
    double endTime1 = SgTime::Get();

    int sum2 = 0;
    for (i = 0; i < NUM_REPETITIONS; ++i)
    {
        for (SgPoint p = board.FirstBoardPoint(); p <= board.LastBoardPoint();
             ++p)
        {   if (board.IsEmpty(p))
                sum2 += p;
        }
    }
    double endTime2 = SgTime::Get();

    int sum3 = 0;
    for (i = 0; i < NUM_REPETITIONS; ++i)
        for (GoBoard::Iterator it(board); it; ++it)
        {
            if (board.IsEmpty(*it))
                sum3 += *it;
        }
    double endTime3 = SgTime::Get();

    int sum4 = 0;
    for (i = 0; i < NUM_REPETITIONS; ++i)
    {
        for (SgPoint p = 0; p < SG_MAXPOINT; ++p)
        {
            if (board.IsEmpty(p))
                sum4 += p;
        }
    }
    double endTime4 = SgTime::Get();

    int sum5 = 0;
    for (i = 0; i < NUM_REPETITIONS; ++i)
    {
        for (SgPoint p = board.FirstBoardPoint(); p <= board.LastBoardPoint();
             ++p)
        {
            if (board.IsEmpty(p))
                sum5 += p;
        }
    }
    double endTime5 = SgTime::Get();

    SG_ASSERT(sum1 == sum2);
    SG_ASSERT(sum2 == sum3);
    SG_ASSERT(sum3 == sum4);
    SG_ASSERT(sum4 == sum5);

    double time1 = endTime1 - startTime;
    double time2 = endTime2 - endTime1;
    double time3 = endTime3 - endTime2;
    double time4 = endTime4 - endTime3;
    double time5 = endTime5 - endTime4;

    out << "Time1: " << time1 << " For 0..SG_MAXPOINT\n"
        << "Time2: " << time2 << " First/LastBoardPoint\n"
        << "Time3: " << time3 << " GoBoard::Iterator\n"
        << "Time4: " << time4 << " For 0..SG_MAXPOINT, no dependency\n"
        << "Time5: " << time5 << " First/LastBoardPoint, no dependency\n";
}
开发者ID:Nopik,项目名称:dragongoclient,代码行数:77,代码来源:GoBoardCheckPerformance.cpp


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