| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 <ctype.h> | 8 #include <ctype.h> |
| 9 | 9 |
| 10 #include "Benchmark.h" | 10 #include "Benchmark.h" |
| 11 #include "CrashHandler.h" | 11 #include "CrashHandler.h" |
| 12 #include "GMBench.h" | 12 #include "GMBench.h" |
| 13 #include "ProcStats.h" | 13 #include "ProcStats.h" |
| 14 #include "ResultsWriter.h" | 14 #include "ResultsWriter.h" |
| 15 #include "SKPBench.h" | 15 #include "SKPBench.h" |
| 16 #include "Stats.h" | 16 #include "Stats.h" |
| 17 #include "Timer.h" | 17 #include "Timer.h" |
| 18 | 18 |
| 19 #include "SkOSFile.h" | 19 #include "SkBBHFactory.h" |
| 20 #include "SkCanvas.h" | 20 #include "SkCanvas.h" |
| 21 #include "SkCommonFlags.h" | 21 #include "SkCommonFlags.h" |
| 22 #include "SkForceLinking.h" | 22 #include "SkForceLinking.h" |
| 23 #include "SkGraphics.h" | 23 #include "SkGraphics.h" |
| 24 #include "SkOSFile.h" |
| 25 #include "SkPictureRecorder.h" |
| 24 #include "SkString.h" | 26 #include "SkString.h" |
| 25 #include "SkSurface.h" | 27 #include "SkSurface.h" |
| 26 | 28 |
| 27 #if SK_SUPPORT_GPU | 29 #if SK_SUPPORT_GPU |
| 28 #include "gl/GrGLDefines.h" | 30 #include "gl/GrGLDefines.h" |
| 29 #include "GrContextFactory.h" | 31 #include "GrContextFactory.h" |
| 30 SkAutoTDelete<GrContextFactory> gGrFactory; | 32 SkAutoTDelete<GrContextFactory> gGrFactory; |
| 31 #endif | 33 #endif |
| 32 | 34 |
| 33 __SK_FORCE_IMAGE_DECODER_LINKING; | 35 __SK_FORCE_IMAGE_DECODER_LINKING; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 64 DEFINE_int32(maxCalibrationAttempts, 3, | 66 DEFINE_int32(maxCalibrationAttempts, 3, |
| 65 "Try up to this many times to guess loops for a bench, or skip the
bench."); | 67 "Try up to this many times to guess loops for a bench, or skip the
bench."); |
| 66 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); | 68 DEFINE_int32(maxLoops, 1000000, "Never run a bench more times than this."); |
| 67 DEFINE_string(properties, "", | 69 DEFINE_string(properties, "", |
| 68 "Space-separated key/value pairs to add to JSON identifying this n
anobench run."); | 70 "Space-separated key/value pairs to add to JSON identifying this n
anobench run."); |
| 69 DEFINE_string(key, "", | 71 DEFINE_string(key, "", |
| 70 "Space-separated key/value pairs to add to JSON identifying this b
ench config."); | 72 "Space-separated key/value pairs to add to JSON identifying this b
ench config."); |
| 71 | 73 |
| 72 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); | 74 DEFINE_string(clip, "0,0,1000,1000", "Clip for SKPs."); |
| 73 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); | 75 DEFINE_string(scales, "1.0", "Space-separated scales for SKPs."); |
| 76 DEFINE_bool(bbh, true, "Build a BBH for SKPs?"); |
| 74 | 77 |
| 75 static SkString humanize(double ms) { | 78 static SkString humanize(double ms) { |
| 76 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); | 79 if (ms > 1e+3) return SkStringPrintf("%.3gs", ms/1e3); |
| 77 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); | 80 if (ms < 1e-3) return SkStringPrintf("%.3gns", ms*1e6); |
| 78 #ifdef SK_BUILD_FOR_WIN | 81 #ifdef SK_BUILD_FOR_WIN |
| 79 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); | 82 if (ms < 1) return SkStringPrintf("%.3gus", ms*1e3); |
| 80 #else | 83 #else |
| 81 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); | 84 if (ms < 1) return SkStringPrintf("%.3gµs", ms*1e3); |
| 82 #endif | 85 #endif |
| 83 return SkStringPrintf("%.3gms", ms); | 86 return SkStringPrintf("%.3gms", ms); |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 477 } |
| 475 | 478 |
| 476 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream.g
et())); | 479 SkAutoTUnref<SkPicture> pic(SkPicture::CreateFromStream(stream.g
et())); |
| 477 if (pic.get() == NULL) { | 480 if (pic.get() == NULL) { |
| 478 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str(
)); | 481 SkDebugf("Could not read %s as an SkPicture.\n", path.c_str(
)); |
| 479 exit(1); | 482 exit(1); |
| 480 } | 483 } |
| 481 | 484 |
| 482 SkString name = SkOSPath::Basename(path.c_str()); | 485 SkString name = SkOSPath::Basename(path.c_str()); |
| 483 | 486 |
| 487 if (FLAGS_bbh) { |
| 488 // The SKP we read off disk doesn't have a BBH. Re-record s
o it grows one. |
| 489 // Here we use an SkTileGrid with parameters optimized for F
LAGS_clip. |
| 490 const SkTileGridFactory::TileGridInfo info = { |
| 491 SkISize::Make(fClip.width(), fClip.height()), // tile i
nterval |
| 492 SkISize::Make(0,0), // margin |
| 493 SkIPoint::Make(fClip.left(), fClip.top()), // offset |
| 494 }; |
| 495 SkTileGridFactory factory(info); |
| 496 SkPictureRecorder recorder; |
| 497 pic->draw(recorder.beginRecording(pic->width(), pic->height(
), &factory)); |
| 498 pic.reset(recorder.endRecording()); |
| 499 } |
| 500 |
| 484 fSourceType = "skp"; | 501 fSourceType = "skp"; |
| 485 return SkNEW_ARGS(SKPBench, | 502 return SkNEW_ARGS(SKPBench, |
| 486 (name.c_str(), pic.get(), fClip, fScales[fCurrentScale])
); | 503 (name.c_str(), pic.get(), fClip, fScales[fCurrentScale])
); |
| 487 } | 504 } |
| 488 fCurrentSKP = 0; | 505 fCurrentSKP = 0; |
| 489 fCurrentScale++; | 506 fCurrentScale++; |
| 490 } | 507 } |
| 491 | 508 |
| 492 return NULL; | 509 return NULL; |
| 493 } | 510 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 | 699 |
| 683 return 0; | 700 return 0; |
| 684 } | 701 } |
| 685 | 702 |
| 686 #if !defined SK_BUILD_FOR_IOS | 703 #if !defined SK_BUILD_FOR_IOS |
| 687 int main(int argc, char** argv) { | 704 int main(int argc, char** argv) { |
| 688 SkCommandLineFlags::Parse(argc, argv); | 705 SkCommandLineFlags::Parse(argc, argv); |
| 689 return nanobench_main(); | 706 return nanobench_main(); |
| 690 } | 707 } |
| 691 #endif | 708 #endif |
| OLD | NEW |