Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Unified Diff: src/gpu/gr_unittests.cpp

Issue 88113002: Speed up GrResourceCache lookup by inlining GrBinHashKey comparisons (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address review comments (capitalized statics) Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrTextureStripAtlas.h ('k') | tests/GrUnitTests.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gr_unittests.cpp
diff --git a/src/gpu/gr_unittests.cpp b/src/gpu/gr_unittests.cpp
deleted file mode 100644
index ae9f67f28e4c68143bdf1d07c30f1cc922936308..0000000000000000000000000000000000000000
--- a/src/gpu/gr_unittests.cpp
+++ /dev/null
@@ -1,80 +0,0 @@
-
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "GrBinHashKey.h"
-#include "GrDrawTarget.h"
-#include "SkMatrix.h"
-#include "GrRedBlackTree.h"
-
-// FIXME: needs to be in a header
-void gr_run_unittests();
-
-// If we aren't inheriting these as #defines from elsewhere,
-// clang demands they be declared before we #include the template
-// that relies on them.
-#ifdef SK_DEBUG
-static bool LT(const int& elem, int value) {
- return elem < value;
-}
-static bool EQ(const int& elem, int value) {
- return elem == value;
-}
-#include "GrTBSearch.h"
-
-static void test_bsearch() {
- const int array[] = {
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 22, 33, 44, 55, 66, 77, 88, 99
- };
-
- for (int n = 0; n < static_cast<int>(GR_ARRAY_COUNT(array)); ++n) {
- for (int i = 0; i < n; i++) {
- int index = GrTBSearch<int, int>(array, n, array[i]);
- SkASSERT(index == (int) i);
- index = GrTBSearch<int, int>(array, n, -array[i]);
- SkASSERT(index < 0);
- }
- }
-}
-#endif
-
-// bogus empty class for GrBinHashKey
-class BogusEntry {};
-
-static void test_binHashKey()
-{
- const char* testStringA_ = "abcdABCD";
- const char* testStringB_ = "abcdBBCD";
- const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_);
- const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(testStringB_);
- enum {
- kDataLenUsedForKey = 8
- };
-
- GrTBinHashKey<BogusEntry, kDataLenUsedForKey> keyA;
- keyA.setKeyData(testStringA);
- // test copy constructor and comparison
- GrTBinHashKey<BogusEntry, kDataLenUsedForKey> keyA2(keyA);
- SkASSERT(keyA.compare(keyA2) == 0);
- SkASSERT(keyA.getHash() == keyA2.getHash());
- // test re-init
- keyA2.setKeyData(testStringA);
- SkASSERT(keyA.compare(keyA2) == 0);
- SkASSERT(keyA.getHash() == keyA2.getHash());
- // test sorting
- GrTBinHashKey<BogusEntry, kDataLenUsedForKey> keyB;
- keyB.setKeyData(testStringB);
- SkASSERT(keyA.compare(keyB) < 0);
- SkASSERT(keyA.getHash() != keyB.getHash());
-}
-
-
-void gr_run_unittests() {
- SkDEBUGCODE(test_bsearch();)
- test_binHashKey();
- GrRedBlackTree<int>::UnitTest();
-}
« no previous file with comments | « src/gpu/effects/GrTextureStripAtlas.h ('k') | tests/GrUnitTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698