Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 | 9 |
| 10 #include "BenchTimer.h" | 10 #include "BenchTimer.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 | 179 |
| 180 static bool parse_bool_arg(char * const* argv, char* const* stop, bool* var) { | 180 static bool parse_bool_arg(char * const* argv, char* const* stop, bool* var) { |
| 181 if (argv < stop) { | 181 if (argv < stop) { |
| 182 *var = atoi(*argv) != 0; | 182 *var = atoi(*argv) != 0; |
| 183 return true; | 183 return true; |
| 184 } | 184 } |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 enum Backend { | 188 enum Backend { |
| 189 kNonRendering_Backend, | |
| 189 kRaster_Backend, | 190 kRaster_Backend, |
| 190 kGPU_Backend, | 191 kGPU_Backend, |
| 191 kPDF_Backend, | 192 kPDF_Backend, |
| 192 }; | 193 }; |
| 193 | 194 |
| 194 static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size, | 195 static SkDevice* make_device(SkBitmap::Config config, const SkIPoint& size, |
| 195 Backend backend, GrContext* context) { | 196 Backend backend, GrContext* context) { |
| 196 SkDevice* device = NULL; | 197 SkDevice* device = NULL; |
| 197 SkBitmap bitmap; | 198 SkBitmap bitmap; |
| 198 bitmap.setConfig(config, size.fX, size.fY); | 199 bitmap.setConfig(config, size.fX, size.fY); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 233 typedef int GLContextType; | 234 typedef int GLContextType; |
| 234 static const GLContextType kDontCareGLCtxType = 0; | 235 static const GLContextType kDontCareGLCtxType = 0; |
| 235 #endif | 236 #endif |
| 236 | 237 |
| 237 static const struct { | 238 static const struct { |
| 238 SkBitmap::Config fConfig; | 239 SkBitmap::Config fConfig; |
| 239 const char* fName; | 240 const char* fName; |
| 240 Backend fBackend; | 241 Backend fBackend; |
| 241 GLContextType fContextType; | 242 GLContextType fContextType; |
| 242 } gConfigs[] = { | 243 } gConfigs[] = { |
| 243 { SkBitmap::kARGB_8888_Config, "8888", kRaster_Backend, kDontCareGLCtxT ype }, | 244 { SkBitmap::kNo_Config, "NONRENDERING", kNonRendering_Backend, kD ontCareGLCtxType }, |
| 244 { SkBitmap::kRGB_565_Config, "565", kRaster_Backend, kDontCareGLCtxT ype }, | 245 { SkBitmap::kARGB_8888_Config, "8888", kRaster_Backend, kDontCar eGLCtxType }, |
| 246 { SkBitmap::kRGB_565_Config, "565", kRaster_Backend, kDontCar eGLCtxType }, | |
| 245 #if SK_SUPPORT_GPU | 247 #if SK_SUPPORT_GPU |
| 246 { SkBitmap::kARGB_8888_Config, "GPU", kGPU_Backend, GrContextFactory:: kNative_GLContextType }, | 248 { SkBitmap::kARGB_8888_Config, "GPU", kGPU_Backend, GrContextFa ctory::kNative_GLContextType }, |
| 247 #if SK_ANGLE | 249 #if SK_ANGLE |
| 248 { SkBitmap::kARGB_8888_Config, "ANGLE", kGPU_Backend, GrContextFactory:: kANGLE_GLContextType }, | 250 { SkBitmap::kARGB_8888_Config, "ANGLE", kGPU_Backend, GrContextFa ctory::kANGLE_GLContextType }, |
| 249 #endif // SK_ANGLE | 251 #endif // SK_ANGLE |
| 250 #ifdef SK_DEBUG | 252 #ifdef SK_DEBUG |
| 251 { SkBitmap::kARGB_8888_Config, "Debug", kGPU_Backend, GrContextFactory:: kDebug_GLContextType }, | 253 { SkBitmap::kARGB_8888_Config, "Debug", kGPU_Backend, GrContextFa ctory::kDebug_GLContextType }, |
| 252 #endif // SK_DEBUG | 254 #endif // SK_DEBUG |
| 253 { SkBitmap::kARGB_8888_Config, "NULLGPU", kGPU_Backend, GrContextFactory:: kNull_GLContextType }, | 255 { SkBitmap::kARGB_8888_Config, "NULLGPU", kGPU_Backend, GrContextFa ctory::kNull_GLContextType }, |
| 254 #endif // SK_SUPPORT_GPU | 256 #endif // SK_SUPPORT_GPU |
| 255 }; | 257 }; |
| 256 | 258 |
| 257 static int findConfig(const char config[]) { | 259 static int findConfig(const char config[]) { |
| 258 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { | 260 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) { |
| 259 if (!strcmp(config, gConfigs[i].fName)) { | 261 if (!strcmp(config, gConfigs[i].fName)) { |
| 260 return i; | 262 return i; |
| 261 } | 263 } |
| 262 } | 264 } |
| 263 return -1; | 265 return -1; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 SkDebugf(" --match name : Only run bench whose name is matched.\n"); | 320 SkDebugf(" --match name : Only run bench whose name is matched.\n"); |
| 319 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n " | 321 SkDebugf(" --mode normal|deferred|deferredSilent|record|picturerecord :\n " |
| 320 " Run in the corresponding mode\n" | 322 " Run in the corresponding mode\n" |
| 321 " normal, Use a normal canvas to draw to;\n" | 323 " normal, Use a normal canvas to draw to;\n" |
| 322 " deferred, Use a deferrred canvas when drawing;\n" | 324 " deferred, Use a deferrred canvas when drawing;\n" |
| 323 " deferredSilent, deferred with silent playback;\n" | 325 " deferredSilent, deferred with silent playback;\n" |
| 324 " record, Benchmark the time to record to an SkPict ure;\n" | 326 " record, Benchmark the time to record to an SkPict ure;\n" |
| 325 " picturerecord, Benchmark the time to do record fr om a \n" | 327 " picturerecord, Benchmark the time to do record fr om a \n" |
| 326 " SkPicture to a SkPicture.\n"); | 328 " SkPicture to a SkPicture.\n"); |
| 327 SkDebugf(" --logFile filename : destination for writing log output, in ad dition to stdout.\n"); | 329 SkDebugf(" --logFile filename : destination for writing log output, in ad dition to stdout.\n"); |
| 328 #if SK_SUPPORT_GPU | 330 SkDebugf(" --config "); |
| 329 SkDebugf(" --config 8888|565|GPU|ANGLE|NULLGPU : " | 331 static const int kConfigCount = SK_ARRAY_COUNT(gConfigs); |
|
robertphillips
2013/03/14 21:13:51
size_t -> int? or kConfigCount -> size_t?
bsalomon
2013/03/15 15:44:10
Done. (kConfigCount -> size_t).
| |
| 330 "Run bench in corresponding config mode.\n"); | 332 for (size_t i = 0; i < kConfigCount; ++i) { |
| 331 #else | 333 SkDebugf("%s%s", gConfigs[i].fName, ((i == kConfigCount - 1) ? "" : "|") ); |
| 332 SkDebugf(" --config 8888|565: " | 334 } |
| 333 "Run bench in corresponding config mode.\n"); | 335 SkDebugf(" : Run bench in corresponding config mode.\n"); |
| 334 #endif | |
| 335 SkDebugf(" -Dfoo bar : Add extra definition to bench.\n"); | 336 SkDebugf(" -Dfoo bar : Add extra definition to bench.\n"); |
| 336 SkDebugf(" -h|--help : Show this help message.\n"); | 337 SkDebugf(" -h|--help : Show this help message.\n"); |
| 337 } | 338 } |
| 338 | 339 |
| 339 int tool_main(int argc, char** argv); | 340 int tool_main(int argc, char** argv); |
| 340 int tool_main(int argc, char** argv) { | 341 int tool_main(int argc, char** argv) { |
| 341 #if SK_ENABLE_INST_COUNT | 342 #if SK_ENABLE_INST_COUNT |
| 342 gPrintInstCount = true; | 343 gPrintInstCount = true; |
| 343 #endif | 344 #endif |
| 344 SkAutoGraphics ag; | 345 SkAutoGraphics ag; |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 if ((benchMode == kRecord_benchModes || benchMode == kPictureRecord_benchMod es)) { | 586 if ((benchMode == kRecord_benchModes || benchMode == kPictureRecord_benchMod es)) { |
| 586 perIterTimeformat.set("%.4f"); | 587 perIterTimeformat.set("%.4f"); |
| 587 normalTimeFormat.set("%6.4f"); | 588 normalTimeFormat.set("%6.4f"); |
| 588 } | 589 } |
| 589 if (!userConfig) { | 590 if (!userConfig) { |
| 590 // if no config is specified by user, we add them all. | 591 // if no config is specified by user, we add them all. |
| 591 for (unsigned int i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { | 592 for (unsigned int i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { |
| 592 *configs.append() = i; | 593 *configs.append() = i; |
| 593 } | 594 } |
| 594 } | 595 } |
| 596 if (kNormal_benchModes != benchMode) { | |
| 597 // Non-rendering configs only run in normal mode | |
| 598 for (int i = 0; i < configs.count(); ++i) { | |
| 599 int configIdx = configs[i]; | |
| 600 if (kNonRendering_Backend == gConfigs[configIdx].fBackend) { | |
| 601 configs.remove(i, 1); | |
| 602 --i; | |
| 603 } | |
| 604 } | |
| 605 } | |
| 595 | 606 |
| 596 // report our current settings | 607 // report our current settings |
| 597 { | 608 { |
| 598 SkString str; | 609 SkString str; |
| 599 const char* deferredMode = benchMode == kDeferred_benchModes ? "yes" : | 610 const char* deferredMode = benchMode == kDeferred_benchModes ? "yes" : |
| 600 (benchMode == kDeferredSilent_benchModes ? "silent" : "no"); | 611 (benchMode == kDeferredSilent_benchModes ? "silent" : "no"); |
| 601 str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d " | 612 str.printf("skia bench: alpha=0x%02X antialias=%d filter=%d " |
| 602 "deferred=%s logperiter=%d", | 613 "deferred=%s logperiter=%d", |
| 603 forceAlpha, forceAA, forceFilter, deferredMode, | 614 forceAlpha, forceAA, forceFilter, deferredMode, |
| 604 logPerIter); | 615 logPerIter); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 bench->setDither(forceDither); | 701 bench->setDither(forceDither); |
| 691 if (hasStrokeWidth) { | 702 if (hasStrokeWidth) { |
| 692 bench->setStrokeWidth(strokeWidth); | 703 bench->setStrokeWidth(strokeWidth); |
| 693 } | 704 } |
| 694 | 705 |
| 695 // only run benchmarks if their name contains matchStr | 706 // only run benchmarks if their name contains matchStr |
| 696 if (skip_name(fMatches, bench->getName())) { | 707 if (skip_name(fMatches, bench->getName())) { |
| 697 continue; | 708 continue; |
| 698 } | 709 } |
| 699 | 710 |
| 700 { | 711 bool loggedBenchStart = false; |
| 701 SkString str; | |
| 702 str.printf("running bench [%d %d] %28s", dim.fX, dim.fY, | |
| 703 bench->getName()); | |
| 704 logger.logProgress(str); | |
| 705 } | |
| 706 | 712 |
| 707 AutoPrePostDraw appd(bench); | 713 AutoPrePostDraw appd(bench); |
| 708 | 714 |
| 709 bool runOnce = false; | |
| 710 for (int x = 0; x < configs.count(); ++x) { | 715 for (int x = 0; x < configs.count(); ++x) { |
| 711 if (!bench->isRendering() && runOnce) { | 716 int configIndex = configs[x]; |
| 712 continue; | 717 |
| 718 if (kNonRendering_Backend == gConfigs[configIndex].fBackend) { | |
| 719 if (bench->isRendering()) { | |
| 720 continue; | |
| 721 } | |
| 722 } else { | |
| 723 if (!bench->isRendering()) { | |
| 724 continue; | |
| 725 } | |
| 713 } | 726 } |
| 714 runOnce = true; | |
| 715 | |
| 716 int configIndex = configs[x]; | |
| 717 | 727 |
| 718 outConfig = gConfigs[configIndex].fConfig; | 728 outConfig = gConfigs[configIndex].fConfig; |
| 719 configName = gConfigs[configIndex].fName; | 729 configName = gConfigs[configIndex].fName; |
| 720 backend = gConfigs[configIndex].fBackend; | 730 backend = gConfigs[configIndex].fBackend; |
| 721 GrContext* context = NULL; | 731 GrContext* context = NULL; |
| 722 BenchTimer* timer = timers[configIndex]; | 732 BenchTimer* timer = timers[configIndex]; |
| 723 | 733 |
| 724 #if SK_SUPPORT_GPU | 734 #if SK_SUPPORT_GPU |
| 725 SkGLContextHelper* glContext = NULL; | 735 SkGLContextHelper* glContext = NULL; |
| 726 if (kGPU_Backend == backend) { | 736 if (kGPU_Backend == backend) { |
| 727 context = gContextFactory.get(gConfigs[configIndex].fContextType ); | 737 context = gContextFactory.get(gConfigs[configIndex].fContextType ); |
| 728 if (NULL == context) { | 738 if (NULL == context) { |
| 729 continue; | 739 continue; |
| 730 } | 740 } |
| 731 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f ContextType); | 741 glContext = gContextFactory.getGLContext(gConfigs[configIndex].f ContextType); |
| 732 } | 742 } |
| 733 #endif | 743 #endif |
| 734 SkDevice* device = make_device(outConfig, dim, backend, context); | 744 SkDevice* device = NULL; |
| 735 SkCanvas* canvas = NULL; | 745 SkCanvas* canvas = NULL; |
| 736 SkPicture pictureRecordFrom; | 746 SkPicture pictureRecordFrom; |
| 737 SkPicture pictureRecordTo; | 747 SkPicture pictureRecordTo; |
| 738 switch(benchMode) { | 748 |
| 739 case kDeferredSilent_benchModes: | 749 if (kNonRendering_Backend != backend) { |
| 740 case kDeferred_benchModes: | 750 device = make_device(outConfig, dim, backend, context); |
| 741 canvas = new SkDeferredCanvas(device); | 751 |
| 742 break; | 752 switch(benchMode) { |
| 743 case kRecord_benchModes: | 753 case kDeferredSilent_benchModes: |
| 744 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, | 754 case kDeferred_benchModes: |
| 745 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 755 canvas = new SkDeferredCanvas(device); |
| 746 canvas->ref(); | 756 break; |
| 747 break; | 757 case kRecord_benchModes: |
| 748 case kPictureRecord_benchModes: { | 758 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, |
| 749 // This sets up picture-to-picture recording. | 759 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 750 // The C++ drawing calls for the benchmark are recorded into | 760 canvas->ref(); |
| 751 // pictureRecordFrom. As the benchmark, we will time how | 761 break; |
| 752 // long it takes to playback pictureRecordFrom into | 762 case kPictureRecord_benchModes: { |
| 753 // pictureRecordTo. | 763 // This sets up picture-to-picture recording. |
| 754 SkCanvas* tempCanvas = pictureRecordFrom.beginRecording(dim. fX, dim.fY, | 764 // The C++ drawing calls for the benchmark are recorded into |
| 755 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 765 // pictureRecordFrom. As the benchmark, we will time how |
| 756 bench->draw(tempCanvas); | 766 // long it takes to playback pictureRecordFrom into |
| 757 pictureRecordFrom.endRecording(); | 767 // pictureRecordTo. |
| 758 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, | 768 SkCanvas* tempCanvas = pictureRecordFrom.beginRecording( dim.fX, dim.fY, |
| 759 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 769 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 760 canvas->ref(); | 770 bench->draw(tempCanvas); |
| 761 break; | 771 pictureRecordFrom.endRecording(); |
| 772 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, | |
| 773 SkPicture::kUsePathBoundsForClip_RecordingFlag); | |
| 774 canvas->ref(); | |
| 775 break; | |
| 776 } | |
| 777 case kNormal_benchModes: | |
| 778 canvas = new SkCanvas(device); | |
| 779 break; | |
| 780 default: | |
| 781 SkASSERT(0); | |
| 762 } | 782 } |
| 763 case kNormal_benchModes: | 783 device->unref(); |
| 764 canvas = new SkCanvas(device); | |
| 765 break; | |
| 766 default: | |
| 767 SkASSERT(0); | |
| 768 } | 784 } |
| 769 device->unref(); | |
| 770 SkAutoUnref canvasUnref(canvas); | 785 SkAutoUnref canvasUnref(canvas); |
| 771 | 786 |
| 772 if (doClip) { | 787 if (NULL != canvas) { |
| 773 performClip(canvas, dim.fX, dim.fY); | 788 if (doClip) { |
| 789 performClip(canvas, dim.fX, dim.fY); | |
| 790 } | |
| 791 if (doScale) { | |
| 792 performScale(canvas, dim.fX, dim.fY); | |
| 793 } | |
| 794 if (doRotate) { | |
| 795 performRotate(canvas, dim.fX, dim.fY); | |
| 796 } | |
| 774 } | 797 } |
| 775 if (doScale) { | 798 |
| 776 performScale(canvas, dim.fX, dim.fY); | 799 if (!loggedBenchStart) { |
| 777 } | 800 loggedBenchStart = true; |
| 778 if (doRotate) { | 801 SkString str; |
| 779 performRotate(canvas, dim.fX, dim.fY); | 802 str.printf("running bench [%d %d] %28s", dim.fX, dim.fY, bench-> getName()); |
| 803 logger.logProgress(str); | |
| 780 } | 804 } |
| 781 | 805 |
| 782 // warm up caches if needed | 806 // warm up caches if needed |
| 783 if (repeatDraw > 1) { | 807 if (repeatDraw > 1 && NULL != canvas) { |
| 784 #if SK_SUPPORT_GPU | 808 #if SK_SUPPORT_GPU |
| 785 // purge the GPU resources to reduce variance | 809 // purge the GPU resources to reduce variance |
| 786 if (NULL != context) { | 810 if (NULL != context) { |
| 787 context->freeGpuResources(); | 811 context->freeGpuResources(); |
| 788 } | 812 } |
| 789 #endif | 813 #endif |
| 790 SkAutoCanvasRestore acr(canvas, true); | 814 SkAutoCanvasRestore acr(canvas, true); |
| 791 if (benchMode == kPictureRecord_benchModes) { | 815 if (benchMode == kPictureRecord_benchModes) { |
| 792 pictureRecordFrom.draw(canvas); | 816 pictureRecordFrom.draw(canvas); |
| 793 } else { | 817 } else { |
| 794 bench->draw(canvas); | 818 bench->draw(canvas); |
| 795 } | 819 } |
| 796 | 820 |
| 797 if (kDeferredSilent_benchModes == benchMode) { | 821 if (kDeferredSilent_benchModes == benchMode) { |
| 798 static_cast<SkDeferredCanvas*>(canvas)->silentFlush(); | 822 static_cast<SkDeferredCanvas*>(canvas)->silentFlush(); |
| 799 } else { | 823 } else { |
| 800 canvas->flush(); | 824 canvas->flush(); |
| 801 } | 825 } |
| 802 #if SK_SUPPORT_GPU | 826 #if SK_SUPPORT_GPU |
| 803 if (NULL != context) { | 827 if (NULL != context) { |
| 804 context->flush(); | 828 context->flush(); |
| 805 SK_GL(*glContext, Finish()); | 829 SK_GL(*glContext, Finish()); |
| 806 } | 830 } |
| 807 #endif | 831 #endif |
| 808 } | 832 } |
| 809 | 833 |
| 810 // record timer values for each repeat, and their sum | 834 // record timer values for each repeat, and their sum |
| 811 TimerData timerData(perIterTimeformat, normalTimeFormat); | 835 TimerData timerData(perIterTimeformat, normalTimeFormat); |
| 812 for (int i = 0; i < repeatDraw; i++) { | 836 for (int i = 0; i < repeatDraw; i++) { |
| 813 if ((benchMode == kRecord_benchModes | 837 if ((benchMode == kRecord_benchModes || benchMode == kPictureRec ord_benchModes)) { |
| 814 || benchMode == kPictureRecord_benchModes)) { | |
| 815 // This will clear the recorded commands so that they do not | 838 // This will clear the recorded commands so that they do not |
| 816 // accumulate. | 839 // accumulate. |
| 817 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, | 840 canvas = pictureRecordTo.beginRecording(dim.fX, dim.fY, |
| 818 SkPicture::kUsePathBoundsForClip_RecordingFlag); | 841 SkPicture::kUsePathBoundsForClip_RecordingFlag); |
| 819 } | 842 } |
| 820 | 843 |
| 821 timer->start(); | 844 timer->start(); |
| 822 SkAutoCanvasRestore acr(canvas, true); | 845 if (NULL != canvas) { |
| 846 canvas->save(); | |
| 847 } | |
| 823 if (benchMode == kPictureRecord_benchModes) { | 848 if (benchMode == kPictureRecord_benchModes) { |
| 824 pictureRecordFrom.draw(canvas); | 849 pictureRecordFrom.draw(canvas); |
| 825 } else { | 850 } else { |
| 826 bench->draw(canvas); | 851 bench->draw(canvas); |
| 827 } | 852 } |
| 828 | 853 |
| 829 if (kDeferredSilent_benchModes == benchMode) { | 854 if (kDeferredSilent_benchModes == benchMode) { |
| 830 static_cast<SkDeferredCanvas*>(canvas)->silentFlush(); | 855 static_cast<SkDeferredCanvas*>(canvas)->silentFlush(); |
| 831 } else { | 856 } else if (NULL != canvas) { |
| 832 canvas->flush(); | 857 canvas->flush(); |
| 833 } | 858 } |
| 834 | 859 |
| 860 if (NULL != canvas) { | |
| 861 canvas->restore(); | |
| 862 } | |
| 863 | |
| 835 // stop the truncated timer after the last canvas call but | 864 // stop the truncated timer after the last canvas call but |
| 836 // don't wait for all the GL calls to complete | 865 // don't wait for all the GL calls to complete |
| 837 timer->truncatedEnd(); | 866 timer->truncatedEnd(); |
| 838 #if SK_SUPPORT_GPU | 867 #if SK_SUPPORT_GPU |
| 839 if (NULL != glContext) { | 868 if (NULL != glContext) { |
| 840 context->flush(); | 869 context->flush(); |
| 841 SK_GL(*glContext, Finish()); | 870 SK_GL(*glContext, Finish()); |
| 842 } | 871 } |
| 843 #endif | 872 #endif |
| 844 // stop the inclusive and gpu timers once all the GL calls | 873 // stop the inclusive and gpu timers once all the GL calls |
| 845 // have completed | 874 // have completed |
| 846 timer->end(); | 875 timer->end(); |
| 847 | 876 |
| 848 timerData.appendTimes(timer, repeatDraw - 1 == i); | 877 timerData.appendTimes(timer, repeatDraw - 1 == i); |
| 849 | 878 |
| 850 } | 879 } |
| 851 if (repeatDraw > 1) { | 880 if (repeatDraw > 1) { |
| 852 SkString result = timerData.getResult(logPerIter, printMin, repe atDraw, configName, | 881 SkString result = timerData.getResult(logPerIter, printMin, repe atDraw, configName, |
| 853 timerWall, truncatedTimerW all, timerCpu, | 882 timerWall, truncatedTimerW all, timerCpu, |
| 854 truncatedTimerCpu, | 883 truncatedTimerCpu, |
| 855 timerGpu && NULL != contex t); | 884 timerGpu && NULL != contex t); |
| 856 logger.logProgress(result); | 885 logger.logProgress(result); |
| 857 } | 886 } |
| 858 if (outDir.size() > 0) { | 887 if (outDir.size() > 0 && kNonRendering_Backend != backend) { |
| 859 saveFile(bench->getName(), configName, outDir.c_str(), | 888 saveFile(bench->getName(), configName, outDir.c_str(), |
| 860 device->accessBitmap(false)); | 889 device->accessBitmap(false)); |
| 861 canvas->clear(SK_ColorWHITE); | 890 canvas->clear(SK_ColorWHITE); |
| 862 } | 891 } |
| 863 } | 892 } |
| 864 logger.logProgress(SkString("\n")); | 893 if (loggedBenchStart) { |
| 894 logger.logProgress(SkString("\n")); | |
| 895 } | |
| 865 } | 896 } |
| 866 #if SK_SUPPORT_GPU | 897 #if SK_SUPPORT_GPU |
| 867 #if GR_CACHE_STATS | 898 #if GR_CACHE_STATS |
| 868 for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) { | 899 for (int i = 0; i <= GrContextFactory::kLastGLContextType; ++i) { |
| 869 GrContextFactory::GLContextType ctxType = (GrContextFactory::GLContextTy pe)i; | 900 GrContextFactory::GLContextType ctxType = (GrContextFactory::GLContextTy pe)i; |
| 870 GrContext* context = gContextFactory.get(ctxType); | 901 GrContext* context = gContextFactory.get(ctxType); |
| 871 if (NULL != context) { | 902 if (NULL != context) { |
| 872 SkDebugf("Cache Stats for %s context:\n", GrContextFactory::GLContex tTypeName(ctxType)); | 903 SkDebugf("Cache Stats for %s context:\n", GrContextFactory::GLContex tTypeName(ctxType)); |
| 873 context->printCacheStats(); | 904 context->printCacheStats(); |
| 874 SkDebugf("\n"); | 905 SkDebugf("\n"); |
| 875 } | 906 } |
| 876 } | 907 } |
| 877 #endif | 908 #endif |
| 878 // Destroy the GrContext before the inst tracking printing at main() exit oc curs. | 909 // Destroy the GrContext before the inst tracking printing at main() exit oc curs. |
| 879 gContextFactory.destroyContexts(); | 910 gContextFactory.destroyContexts(); |
| 880 #endif | 911 #endif |
| 881 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { | 912 for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); ++i) { |
| 882 SkDELETE(timers[i]); | 913 SkDELETE(timers[i]); |
| 883 } | 914 } |
| 884 | 915 |
| 885 return 0; | 916 return 0; |
| 886 } | 917 } |
| 887 | 918 |
| 888 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 919 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 889 int main(int argc, char * const argv[]) { | 920 int main(int argc, char * const argv[]) { |
| 890 return tool_main(argc, (char**) argv); | 921 return tool_main(argc, (char**) argv); |
| 891 } | 922 } |
| 892 #endif | 923 #endif |
| OLD | NEW |