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

Side by Side Diff: tools/bench_record.cpp

Issue 258703002: Revert of Add nanosecond timer. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « tools/bench_playback.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkCommandLineFlags.h" 8 #include "SkCommandLineFlags.h"
9 #include "SkForceLinking.h" 9 #include "SkForceLinking.h"
10 #include "SkGraphics.h" 10 #include "SkGraphics.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 return SkNEW_ARGS(SkTileGridFactory, (info)); 49 return SkNEW_ARGS(SkTileGridFactory, (info));
50 } 50 }
51 if (FLAGS_bbh.contains("quadtree")) { 51 if (FLAGS_bbh.contains("quadtree")) {
52 return SkNEW(SkQuadTreeFactory); 52 return SkNEW(SkQuadTreeFactory);
53 } 53 }
54 SkDebugf("Invalid bbh type %s, must be one of rtree, tilegrid, quadtree.\n", FLAGS_bbh[0]); 54 SkDebugf("Invalid bbh type %s, must be one of rtree, tilegrid, quadtree.\n", FLAGS_bbh[0]);
55 return NULL; 55 return NULL;
56 } 56 }
57 57
58 static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFact ory) { 58 static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFact ory) {
59 const SkNSec start = SkTime::GetNSecs(); 59 const SkMSec start = SkTime::GetMSecs();
60 const int width = src ? src->width() : FLAGS_nullSize; 60 const int width = src ? src->width() : FLAGS_nullSize;
61 const int height = src ? src->height() : FLAGS_nullSize; 61 const int height = src ? src->height() : FLAGS_nullSize;
62 62
63 for (int i = 0; i < FLAGS_loops; i++) { 63 for (int i = 0; i < FLAGS_loops; i++) {
64 if (FLAGS_skr) { 64 if (FLAGS_skr) {
65 EXPERIMENTAL::SkRecording recording(width, height); 65 EXPERIMENTAL::SkRecording recording(width, height);
66 if (NULL != src) { 66 if (NULL != src) {
67 src->draw(recording.canvas()); 67 src->draw(recording.canvas());
68 } 68 }
69 // Release and delete the SkPlayback so that recording optimizes its SkRecord. 69 // Release and delete the SkPlayback so that recording optimizes its SkRecord.
70 SkDELETE(recording.releasePlayback()); 70 SkDELETE(recording.releasePlayback());
71 } else { 71 } else {
72 SkPictureRecorder recorder; 72 SkPictureRecorder recorder;
73 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory , FLAGS_flags); 73 SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory , FLAGS_flags);
74 if (NULL != src) { 74 if (NULL != src) {
75 src->draw(canvas); 75 src->draw(canvas);
76 } 76 }
77 if (FLAGS_endRecording) { 77 if (FLAGS_endRecording) {
78 SkAutoTUnref<SkPicture> dst(recorder.endRecording()); 78 SkAutoTUnref<SkPicture> dst(recorder.endRecording());
79 } 79 }
80 } 80 }
81 } 81 }
82 82
83 const SkNSec elapsed = SkTime::GetNSecs() - start; 83 const SkMSec elapsed = SkTime::GetMSecs() - start;
84 const double nsPerLoop = elapsed / (double)FLAGS_loops; 84 const double msPerLoop = elapsed / (double)FLAGS_loops;
85 printf("%u\t%s\n", SkToUInt(nsPerLoop), name); 85 printf("%.2g\t%s\n", msPerLoop, name);
86 } 86 }
87 87
88 int tool_main(int argc, char** argv); 88 int tool_main(int argc, char** argv);
89 int tool_main(int argc, char** argv) { 89 int tool_main(int argc, char** argv) {
90 SkCommandLineFlags::Parse(argc, argv); 90 SkCommandLineFlags::Parse(argc, argv);
91 SkAutoGraphics autoGraphics; 91 SkAutoGraphics autoGraphics;
92 92
93 if (FLAGS_bbh.count() > 1) { 93 if (FLAGS_bbh.count() > 1) {
94 SkDebugf("Multiple bbh arguments supplied.\n"); 94 SkDebugf("Multiple bbh arguments supplied.\n");
95 return 1; 95 return 1;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 bench_record(src, filename.c_str(), bbhFactory.get()); 127 bench_record(src, filename.c_str(), bbhFactory.get());
128 } 128 }
129 return failed ? 1 : 0; 129 return failed ? 1 : 0;
130 } 130 }
131 131
132 #if !defined SK_BUILD_FOR_IOS 132 #if !defined SK_BUILD_FOR_IOS
133 int main(int argc, char * const argv[]) { 133 int main(int argc, char * const argv[]) {
134 return tool_main(argc, (char**) argv); 134 return tool_main(argc, (char**) argv);
135 } 135 }
136 #endif 136 #endif
OLDNEW
« no previous file with comments | « tools/bench_playback.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698