diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-26 23:01:57 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-02-26 23:01:57 +0000 |
commit | 38aeb0fd7a2bdab5e44531d96045dffe25c8e2b0 (patch) | |
tree | c373c1f753a84247e82cc7f2c42b9b728dc40420 /bench | |
parent | 40ac5e52b8d08e85c269c93076fbd4208650d17f (diff) |
DM: also run benches once.
Also:
- make GrMemoryPoolBenches threadsafe
- some tweaks to various DM code
- rename GM::shortName() to getName() to match benches and tests
On my desktop, (289 GMs, 617 benches) x 4 configs, 227 tests takes 46s in Debug, 14s in Release. (Still minutes faster than running tests && bench && gm.) GPU singlethreading is definitely the limiting factor again; going to reexamine whether that's helpful to thread it again.
BUG=skia:
R=reed@google.com, bsalomon@google.com, mtklein@google.com
Author: mtklein@chromium.org
Review URL: https://codereview.chromium.org/178473006
git-svn-id: http://skia.googlecode.com/svn/trunk@13603 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'bench')
-rw-r--r-- | bench/GrMemoryPoolBench.cpp | 36 | ||||
-rw-r--r-- | bench/SkBenchmark.h | 15 | ||||
-rw-r--r-- | bench/SkGMBench.cpp | 2 | ||||
-rw-r--r-- | bench/benchmain.cpp | 2 |
4 files changed, 33 insertions, 22 deletions
diff --git a/bench/GrMemoryPoolBench.cpp b/bench/GrMemoryPoolBench.cpp index 21f686d89d..96526e5fc2 100644 --- a/bench/GrMemoryPoolBench.cpp +++ b/bench/GrMemoryPoolBench.cpp @@ -20,12 +20,12 @@ struct A { int gStuff[10]; #if OVERRIDE_NEW - void* operator new (size_t size) { return gPool.allocate(size); } - void operator delete (void* mem) { if (mem) { return gPool.release(mem); } } + void* operator new (size_t size) { return gBenchPool.allocate(size); } + void operator delete (void* mem) { if (mem) { return gBenchPool.release(mem); } } #endif - static GrMemoryPool gPool; + static GrMemoryPool gBenchPool; }; -GrMemoryPool A::gPool(10 * (1 << 10), 10 * (1 << 10)); +GrMemoryPool A::gBenchPool(10 * (1 << 10), 10 * (1 << 10)); /** * This benchmark creates and deletes objects in stack order @@ -79,6 +79,16 @@ private: typedef SkBenchmark INHERITED; }; +struct B { + int gStuff[10]; +#if OVERRIDE_NEW + void* operator new (size_t size) { return gBenchPool.allocate(size); } + void operator delete (void* mem) { if (mem) { return gBenchPool.release(mem); } } +#endif + static GrMemoryPool gBenchPool; +}; +GrMemoryPool B::gBenchPool(10 * (1 << 10), 10 * (1 << 10)); + /** * This benchmark creates objects and deletes them in random order */ @@ -98,12 +108,12 @@ protected: enum { kMaxObjects = 4 * (1 << 10), }; - SkAutoTDelete<A> objects[kMaxObjects]; + SkAutoTDelete<B> objects[kMaxObjects]; for (int i = 0; i < loops; i++) { uint32_t idx = r.nextRangeU(0, kMaxObjects-1); if (NULL == objects[idx].get()) { - objects[idx].reset(new A); + objects[idx].reset(new B); } else { objects[idx].free(); } @@ -114,6 +124,16 @@ private: typedef SkBenchmark INHERITED; }; +struct C { + int gStuff[10]; +#if OVERRIDE_NEW + void* operator new (size_t size) { return gBenchPool.allocate(size); } + void operator delete (void* mem) { if (mem) { return gBenchPool.release(mem); } } +#endif + static GrMemoryPool gBenchPool; +}; +GrMemoryPool C::gBenchPool(10 * (1 << 10), 10 * (1 << 10)); + /** * This benchmark creates objects and deletes them in queue order */ @@ -133,11 +153,11 @@ protected: virtual void onDraw(const int loops, SkCanvas*) { SkRandom r; - A* objects[M]; + C* objects[M]; for (int i = 0; i < loops; i++) { uint32_t count = r.nextRangeU(0, M-1); for (uint32_t i = 0; i < count; i++) { - objects[i] = new A; + objects[i] = new C; } for (uint32_t i = 0; i < count; i++) { delete objects[i]; diff --git a/bench/SkBenchmark.h b/bench/SkBenchmark.h index f1e317da60..bf28689236 100644 --- a/bench/SkBenchmark.h +++ b/bench/SkBenchmark.h @@ -15,10 +15,8 @@ #define DEF_BENCH(code) \ namespace { \ -class SK_MACRO_APPEND_LINE(F_CLASS) : public SkBenchmarkFactory { \ - virtual SkBenchmark* operator()() const SK_OVERRIDE { code; } \ -} SK_MACRO_APPEND_LINE(g_F_); \ -BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(&SK_MACRO_APPEND_LINE(g_F_)); \ +static SkBenchmark* SK_MACRO_APPEND_LINE(factory)(void*) { code; } \ +BenchRegistry SK_MACRO_APPEND_LINE(g_R_)(SK_MACRO_APPEND_LINE(factory)); \ } /* @@ -136,13 +134,6 @@ private: typedef SkRefCnt INHERITED; }; -class SkBenchmarkFactory : public SkRefCnt { -public: - // Creates a new SkBenchmark that is owned by the caller on each call. - virtual SkBenchmark* operator()() const = 0; - virtual ~SkBenchmarkFactory() {} -}; - -typedef SkTRegistry<SkBenchmarkFactory*> BenchRegistry; +typedef SkTRegistry<SkBenchmark*(*)(void*)> BenchRegistry; #endif diff --git a/bench/SkGMBench.cpp b/bench/SkGMBench.cpp index e1d8124764..77d29a70a9 100644 --- a/bench/SkGMBench.cpp +++ b/bench/SkGMBench.cpp @@ -8,7 +8,7 @@ #include "SkGMBench.h" SkGMBench::SkGMBench(skiagm::GM* gm) : fGM(gm) { - fName.printf("GM:%s", gm->shortName()); + fName.printf("GM:%s", gm->getName()); } SkGMBench::~SkGMBench() { delete fGM; } diff --git a/bench/benchmain.cpp b/bench/benchmain.cpp index 6eea11fc14..2401d6769a 100644 --- a/bench/benchmain.cpp +++ b/bench/benchmain.cpp @@ -58,7 +58,7 @@ public: if (fBenches) { BenchRegistry::Factory f = fBenches->factory(); fBenches = fBenches->next(); - return (*f)(); + return (*f)(NULL); } while (fGMs) { |