180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2011 Google Inc.
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "Test.h"
9910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger#include "TestClassDef.h"
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// This is a GPU-backend specific test
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if SK_SUPPORT_GPU
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "GrMemoryPool.h"
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkRandom.h"
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkTDArray.h"
157839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger#include "SkTemplates.h"
1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkInstCnt.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// A is the top of an inheritance tree of classes that overload op new and
1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// and delete to use a GrMemoryPool. The objects have values of different types
2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// that can be set and checked.
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass A {
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    A() {};
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setValues(int v) {
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fChar = static_cast<char>(v);
2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool checkValues(int v) {
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return fChar == static_cast<char>(v);
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~A() {};
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void* operator new(size_t size) {
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (!gPool.get()) {
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return ::operator new(size);
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else {
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return gPool->allocate(size);
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void operator delete(void* p) {
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (!gPool.get()) {
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            ::operator delete(p);
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        } else {
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return gPool->release(p);
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SK_DECLARE_INST_COUNT_ROOT(A);
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
500a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    static A* Create(SkRandom* r);
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void SetAllocator(size_t preallocSize, size_t minAllocSize) {
53d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger#if SK_ENABLE_INST_COUNT
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(0 == GetInstanceCount());
5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        GrMemoryPool* pool = new GrMemoryPool(preallocSize, minAllocSize);
5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        gPool.reset(pool);
5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void ResetAllocator() {
61d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger#if SK_ENABLE_INST_COUNT
6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkASSERT(0 == GetInstanceCount());
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        gPool.reset(NULL);
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
687839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    static SkAutoTDelete<GrMemoryPool> gPool;
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    char fChar;
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
71910f694aefb0b671dd8522a9afe9b6be645701c1Derek Sollenberger
727839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek SollenbergerSkAutoTDelete<GrMemoryPool> A::gPool;
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass B : public A {
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    B() {};
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setValues(int v) {
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fDouble = static_cast<double>(v);
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this->INHERITED::setValues(v);
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool checkValues(int v) {
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return fDouble == static_cast<double>(v) &&
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru               this->INHERITED::checkValues(v);
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~B() {};
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    double fDouble;
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef A INHERITED;
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass C : public A {
9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    C() {};
9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setValues(int v) {
9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fInt64 = static_cast<int64_t>(v);
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this->INHERITED::setValues(v);
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool checkValues(int v) {
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return fInt64 == static_cast<int64_t>(v) &&
10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru               this->INHERITED::checkValues(v);
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~C() {};
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int64_t fInt64;
10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef A INHERITED;
11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// D derives from C and owns a dynamically created B
11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass D : public C {
11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    D() {
11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fB = new B();
11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setValues(int v) {
11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fVoidStar = reinterpret_cast<void*>(v);
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this->INHERITED::setValues(v);
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fB->setValues(v);
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool checkValues(int v) {
12480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return fVoidStar == reinterpret_cast<void*>(v) &&
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru               fB->checkValues(v) &&
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru               this->INHERITED::checkValues(v);
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~D() {
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        delete fB;
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void*   fVoidStar;
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    B*      fB;
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef C INHERITED;
13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass E : public A {
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    E() {}
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual void setValues(int v) {
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        for (size_t i = 0; i < SK_ARRAY_COUNT(fIntArray); ++i) {
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            fIntArray[i] = v;
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        this->INHERITED::setValues(v);
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual bool checkValues(int v) {
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        bool ok = true;
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        for (size_t i = 0; ok && i < SK_ARRAY_COUNT(fIntArray); ++i) {
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            if (fIntArray[i] != v) {
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                ok = false;
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return ok && this->INHERITED::checkValues(v);
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    virtual ~E() {}
15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int   fIntArray[20];
15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    typedef A INHERITED;
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1630a657bbc2c6fc9daf699942e023050536d5ec95fDerek SollenbergerA* A::Create(SkRandom* r) {
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    switch (r->nextRangeU(0, 4)) {
16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        case 0:
16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return new A;
16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        case 1:
16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return new B;
16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        case 2:
17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return new C;
17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        case 3:
17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return new D;
17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        case 4:
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return new E;
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        default:
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            // suppress warning
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return NULL;
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
1800a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct Rec {
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    A* fInstance;
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int fValue;
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
186910f694aefb0b671dd8522a9afe9b6be645701c1Derek SollenbergerDEF_TEST(GrMemoryPool, reporter) {
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // prealloc and min alloc sizes for the pool
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const size_t gSizes[][2] = {
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {0, 0},
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {10 * sizeof(A), 20 * sizeof(A)},
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {100 * sizeof(A), 100 * sizeof(A)},
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {500 * sizeof(A), 500 * sizeof(A)},
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {10000 * sizeof(A), 0},
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        {1, 100 * sizeof(A)},
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // different percentages of creation vs deletion
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const float gCreateFraction[] = {1.f, .95f, 0.75f, .5f};
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // number of create/destroys per test
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const int kNumIters = 20000;
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // check that all the values stored in A objects are correct after this
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // number of iterations
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static const int kCheckPeriod = 500;
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2040a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SkRandom r;
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    for (size_t s = 0; s < SK_ARRAY_COUNT(gSizes); ++s) {
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        A::SetAllocator(gSizes[s][0], gSizes[s][1]);
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        for (size_t c = 0; c < SK_ARRAY_COUNT(gCreateFraction); ++c) {
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            SkTDArray<Rec> instanceRecs;
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            for (int i = 0; i < kNumIters; ++i) {
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                float createOrDestroy = r.nextUScalar1();
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                if (createOrDestroy < gCreateFraction[c] ||
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    0 == instanceRecs.count()) {
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    Rec* rec = instanceRecs.append();
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    rec->fInstance = A::Create(&r);
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    rec->fValue = static_cast<int>(r.nextU());
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    rec->fInstance->setValues(rec->fValue);
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                } else {
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    int d = r.nextRangeU(0, instanceRecs.count() - 1);
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    Rec& rec = instanceRecs[d];
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue));
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    delete rec.fInstance;
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    instanceRecs.removeShuffle(d);
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                }
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                if (0 == i % kCheckPeriod) {
22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    for (int r = 0; r < instanceRecs.count(); ++r) {
22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        Rec& rec = instanceRecs[r];
22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue));
22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    }
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                }
23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            for (int i = 0; i < instanceRecs.count(); ++i) {
23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                Rec& rec = instanceRecs[i];
23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                REPORTER_ASSERT(reporter, rec.fInstance->checkValues(rec.fValue));
23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                delete rec.fInstance;
23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
236d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger#if SK_ENABLE_INST_COUNT
23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            REPORTER_ASSERT(reporter, !A::GetInstanceCount());
23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}
24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
244