| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkBenchmark.h" | 8 #include "SkBenchmark.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 virtual void onDraw(SkCanvas*) SK_OVERRIDE { | 53 virtual void onDraw(SkCanvas*) SK_OVERRIDE { |
| 54 #ifdef SK_DEBUG | 54 #ifdef SK_DEBUG |
| 55 if (!fValid) { | 55 if (!fValid) { |
| 56 SkDebugf("stream was invalid: %s\n", fName.c_str()); | 56 SkDebugf("stream was invalid: %s\n", fName.c_str()); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 #endif | 59 #endif |
| 60 // Decode a bunch of times | 60 // Decode a bunch of times |
| 61 SkBitmap bm; | 61 SkBitmap bm; |
| 62 for (int i = 0; i < SkBENCHLOOP(1000); ++i) { | 62 for (int i = 0; i < this->getLoops(); ++i) { |
| 63 SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &
bm); | 63 SkDEBUGCODE(bool success =) SkImageDecoder::DecodeStream(&fStream, &
bm); |
| 64 #ifdef SK_DEBUG | 64 #ifdef SK_DEBUG |
| 65 if (!success) { | 65 if (!success) { |
| 66 SkDebugf("failed to decode %s\n", fName.c_str()); | 66 SkDebugf("failed to decode %s\n", fName.c_str()); |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 #endif | 69 #endif |
| 70 SkDEBUGCODE(success =) fStream.rewind(); | 70 SkDEBUGCODE(success =) fStream.rewind(); |
| 71 #ifdef SK_DEBUG | 71 #ifdef SK_DEBUG |
| 72 if (!success) { | 72 if (!success) { |
| 73 SkDebugf("failed to rewind %s\n", fName.c_str()); | 73 SkDebugf("failed to rewind %s\n", fName.c_str()); |
| 74 return; | 74 return; |
| 75 } | 75 } |
| 76 #endif | 76 #endif |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 SkString fName; | 81 SkString fName; |
| 82 const SkString fFilename; | 82 const SkString fFilename; |
| 83 SkMemoryStream fStream; | 83 SkMemoryStream fStream; |
| 84 bool fValid; | 84 bool fValid; |
| 85 | 85 |
| 86 typedef SkBenchmark INHERITED; | 86 typedef SkBenchmark INHERITED; |
| 87 }; | 87 }; |
| 88 | 88 |
| 89 // These are files which call decodePalette | 89 // These are files which call decodePalette |
| 90 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, (p, "/usr/local/google/home/scr
oggo/Downloads/images/hal_163x90.png")); ) | 90 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, (p, "/usr/local/google/home/scr
oggo/Downloads/images/hal_163x90.png")); ) |
| 91 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, (p, "/usr/local/google/home/scr
oggo/Downloads/images/box_19_top-left.png")); ) | 91 //DEF_BENCH( return SkNEW_ARGS(ImageDecodeBench, (p, "/usr/local/google/home/scr
oggo/Downloads/images/box_19_top-left.png")); ) |
| OLD | NEW |