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

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

Issue 1386933002: Cleanup timing state machine (Closed) Base URL: https://skia.googlesource.com/skia.git@vb2
Patch Set: rebase Created 5 years, 2 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/Benchmark.h ('k') | tools/VisualBench/TimingStateMachine.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 TimingStateMachine_DEFINED 9 #ifndef TimingStateMachine_DEFINED
10 #define TimingStateMachine_DEFINED 10 #define TimingStateMachine_DEFINED
(...skipping 18 matching lines...) Expand all
29 public: 29 public:
30 TimingStateMachine(); 30 TimingStateMachine();
31 31
32 enum ParentEvents { 32 enum ParentEvents {
33 kReset_ParentEvents, 33 kReset_ParentEvents,
34 kTiming_ParentEvents, 34 kTiming_ParentEvents,
35 kTimingFinished_ParentEvents,// This implies parent can read lastMeasure ment() and must 35 kTimingFinished_ParentEvents,// This implies parent can read lastMeasure ment() and must
36 // reset 36 // reset
37 }; 37 };
38 38
39 ParentEvents nextFrame(SkCanvas* canvas, Benchmark* benchmark); 39 ParentEvents nextFrame(bool preWarmBetweenSamples);
40
41 /*
42 * Before taking another sample, the owner can choose to prewarm or not
43 */
44 void nextSampleWithPrewarm();
45 void nextSample();
46 40
47 /* 41 /*
48 * The caller should call this when they are ready to move to the next bench mark. The caller 42 * The caller should call this when they are ready to move to the next bench mark. The caller
49 * must call this with the *last* benchmark so post draw hooks can be invoke d 43 * must call this with the *last* benchmark so post draw hooks can be invoke d
50 */ 44 */
51 void nextBenchmark(SkCanvas*, Benchmark*); 45 void nextBenchmark(SkCanvas*, Benchmark*);
52 46
53
54 /* 47 /*
55 * When TimingStateMachine returns kTimingFinished_ParentEvents, then the ow ner can call 48 * When TimingStateMachine returns kTimingFinished_ParentEvents, then the ow ner can call
56 * lastMeasurement() to get the time 49 * lastMeasurement() to get the time
57 */ 50 */
58 double lastMeasurement() const { return fLastMeasurement; } 51 double lastMeasurement() const { return fLastMeasurement; }
59 52
60 int loops() const { return fLoops; } 53 int loops() const { return fLoops; }
61 54
62 private: 55 private:
63 /*
64 * The heart of the timing state machine is an event driven timing loop.
65 * kPreWarmLoopsPerCanvasPreDraw_State: Before we begin timing, Benchmarks have a hook to
66 * access the canvas. Then we prewarm before the autotune
67 * loops step.
68 * kPreWarmLoops_State: We prewarm the gpu before auto tuni ng to enter a steady
69 * work state
70 * kTuneLoops_State: Then we tune the loops of the bench mark to ensure we
71 * are doing a measurable amount of wo rk
72 * kPreWarmTimingPerCanvasPreDraw_State: Because reset the context after tun ing loops to ensure
73 * coherent state, we need to give the benchmark
74 * another hook
75 * kPreWarmTiming_State: We prewarm the gpu again to enter a steady state
76 * kTiming_State: Finally we time the benchmark. Whe n finished timing
77 * if we have enough samples then we'l l start the next
78 * benchmark in the kPreWarmLoopsPerCa nvasPreDraw_State.
79 * otherwise, we enter the
80 * kPreWarmTimingPerCanvasPreDraw_Stat e for another sample
81 * In either case we reset the context .
82 */
83 enum State { 56 enum State {
84 kPreWarmLoopsPerCanvasPreDraw_State, 57 kPreWarm_State,
85 kPreWarmLoops_State,
86 kTuneLoops_State,
87 kPreWarmTimingPerCanvasPreDraw_State,
88 kPreWarmTiming_State,
89 kTiming_State, 58 kTiming_State,
90 }; 59 };
60 enum InnerState {
61 kTuning_InnerState,
62 kTiming_InnerState,
63 };
91 64
92 inline void nextState(State);
93 ParentEvents perCanvasPreDraw(SkCanvas*, Benchmark*, State);
94 ParentEvents preWarm(State nextState);
95 inline ParentEvents tuneLoops();
96 inline ParentEvents timing(SkCanvas*, Benchmark*);
97 inline double elapsed(); 65 inline double elapsed();
98 void resetTimingState(); 66 void resetTimingState();
99 void postDraw(SkCanvas*, Benchmark*);
100 void recordMeasurement(); 67 void recordMeasurement();
101 68
102 int fCurrentFrame; 69 int fCurrentFrame;
103 int fLoops; 70 int fLoops;
104 double fLastMeasurement; 71 double fLastMeasurement;
105 WallTimer fTimer; 72 WallTimer fTimer;
106 State fState; 73 State fState;
74 InnerState fInnerState;
107 }; 75 };
108 76
109 #endif 77 #endif
OLDNEW
« no previous file with comments | « bench/Benchmark.h ('k') | tools/VisualBench/TimingStateMachine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698