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

Side by Side Diff: tools/VisualBench/VisualLightweightBenchModule.h

Issue 1358373003: Add warmup bench to visual bench (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 3 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 | « bench/RectBench.cpp ('k') | tools/VisualBench/VisualLightweightBenchModule.cpp » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 8
9 #ifndef VisualLightweightBenchModule_DEFINED 9 #ifndef VisualLightweightBenchModule_DEFINED
10 #define VisualLightweightBenchModule_DEFINED 10 #define VisualLightweightBenchModule_DEFINED
(...skipping 16 matching lines...) Expand all
27 // TODO get rid of backpointer 27 // TODO get rid of backpointer
28 VisualLightweightBenchModule(VisualBench* owner); 28 VisualLightweightBenchModule(VisualBench* owner);
29 29
30 void draw(SkCanvas* canvas) override; 30 void draw(SkCanvas* canvas) override;
31 31
32 bool onHandleChar(SkUnichar c) override; 32 bool onHandleChar(SkUnichar c) override;
33 33
34 private: 34 private:
35 /* 35 /*
36 * The heart of visual bench is an event driven timing loop. 36 * The heart of visual bench is an event driven timing loop.
37 * kWarmup_State: We run a dummy bench to let things settle on startup
37 * kPreWarmLoopsPerCanvasPreDraw_State: Before we begin timing, Benchmarks have a hook to 38 * kPreWarmLoopsPerCanvasPreDraw_State: Before we begin timing, Benchmarks have a hook to
38 * access the canvas. Then we prewarm before the autotune 39 * access the canvas. Then we prewarm before the autotune
39 * loops step. 40 * loops step.
40 * kPreWarmLoops_State: We prewarm the gpu before auto tuni ng to enter a steady 41 * kPreWarmLoops_State: We prewarm the gpu before auto tuni ng to enter a steady
41 * work state 42 * work state
42 * kTuneLoops_State: Then we tune the loops of the bench mark to ensure we 43 * kTuneLoops_State: Then we tune the loops of the bench mark to ensure we
43 * are doing a measurable amount of wo rk 44 * are doing a measurable amount of wo rk
44 * kPreWarmTimingPerCanvasPreDraw_State: Because reset the context after tun ing loops to ensure 45 * kPreWarmTimingPerCanvasPreDraw_State: Because reset the context after tun ing loops to ensure
45 * coherent state, we need to give the benchmark 46 * coherent state, we need to give the benchmark
46 * another hook 47 * another hook
47 * kPreWarmTiming_State: We prewarm the gpu again to enter a steady state 48 * kPreWarmTiming_State: We prewarm the gpu again to enter a steady state
48 * kTiming_State: Finally we time the benchmark. Whe n finished timing 49 * kTiming_State: Finally we time the benchmark. Whe n finished timing
49 * if we have enough samples then we'l l start the next 50 * if we have enough samples then we'l l start the next
50 * benchmark in the kPreWarmLoopsPerCa nvasPreDraw_State. 51 * benchmark in the kPreWarmLoopsPerCa nvasPreDraw_State.
51 * otherwise, we enter the 52 * otherwise, we enter the
52 * kPreWarmTimingPerCanvasPreDraw_Stat e for another sample 53 * kPreWarmTimingPerCanvasPreDraw_Stat e for another sample
53 * In either case we reset the context . 54 * In either case we reset the context .
54 */ 55 */
55 enum State { 56 enum State {
57 kWarmup_State,
56 kPreWarmLoopsPerCanvasPreDraw_State, 58 kPreWarmLoopsPerCanvasPreDraw_State,
57 kPreWarmLoops_State, 59 kPreWarmLoops_State,
58 kTuneLoops_State, 60 kTuneLoops_State,
59 kPreWarmTimingPerCanvasPreDraw_State, 61 kPreWarmTimingPerCanvasPreDraw_State,
60 kPreWarmTiming_State, 62 kPreWarmTiming_State,
61 kTiming_State, 63 kTiming_State,
62 }; 64 };
63 void setTitle(); 65 void setTitle();
64 bool setupBackend(); 66 bool setupBackend();
65 void setupRenderTarget(); 67 void setupRenderTarget();
66 void printStats(); 68 void printStats();
67 bool advanceRecordIfNecessary(SkCanvas*); 69 bool advanceRecordIfNecessary(SkCanvas*);
68 inline void renderFrame(SkCanvas*); 70 inline void renderFrame(SkCanvas*);
69 inline void nextState(State); 71 inline void nextState(State);
70 void perCanvasPreDraw(SkCanvas*, State); 72 void perCanvasPreDraw(SkCanvas*, State);
71 void preWarm(State nextState); 73 void preWarm(State nextState);
72 void scaleLoops(double elapsedMs); 74 void scaleLoops(double elapsedMs);
73 inline void tuneLoops(); 75 inline void tuneLoops();
74 inline void timing(SkCanvas*); 76 inline void timing(SkCanvas*);
75 inline double elapsed(); 77 inline double elapsed();
76 void resetTimingState(); 78 void resetTimingState();
77 void postDraw(SkCanvas*); 79 void postDraw(SkCanvas*);
78 void recordMeasurement(); 80 void recordMeasurement();
81 void warmup(SkCanvas* canvas);
79 82
80 struct Record { 83 struct Record {
81 SkTArray<double> fMeasurements; 84 SkTArray<double> fMeasurements;
82 }; 85 };
83 86
84 int fCurrentSample; 87 int fCurrentSample;
85 int fCurrentFrame; 88 int fCurrentFrame;
86 int fLoops; 89 int fLoops;
87 SkTArray<Record> fRecords; 90 SkTArray<Record> fRecords;
88 WallTimer fTimer; 91 WallTimer fTimer;
89 State fState; 92 State fState;
90 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream; 93 SkAutoTDelete<VisualBenchmarkStream> fBenchmarkStream;
91 SkAutoTUnref<Benchmark> fBenchmark; 94 SkAutoTUnref<Benchmark> fBenchmark;
92 95
93 // support framework 96 // support framework
94 SkAutoTUnref<VisualBench> fOwner; 97 SkAutoTUnref<VisualBench> fOwner;
95 SkAutoTDelete<ResultsWriter> fResults; 98 SkAutoTDelete<ResultsWriter> fResults;
96 99
97 typedef VisualModule INHERITED; 100 typedef VisualModule INHERITED;
98 }; 101 };
99 102
100 #endif 103 #endif
OLDNEW
« no previous file with comments | « bench/RectBench.cpp ('k') | tools/VisualBench/VisualLightweightBenchModule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698