aboutsummaryrefslogtreecommitdiffhomepage
path: root/samplecode
diff options
context:
space:
mode:
authorGravatar Yuqian Li <liyuqian@google.com>2017-09-25 14:45:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-25 19:12:50 +0000
commit94fddf83816ab846a25134dfc845746187b7733b (patch)
treec3398ce4e5e50c3aa00dcb5765ab078a97580bed /samplecode
parentb449666fa230728fd67b76c990bf49ff726f7134 (diff)
Add measurement command line args to SampleApp
This way, we may be able to use SampleApp as a performance benchmark tool that's closer to real-world use cases than nanobench. For example, we can now run ./out/Release/SampleApp --slide Chart --backendTiles 8 --measureMS 2000 to test the threaded backend. Bug: skia: Change-Id: I92b177624bc8d16c5b4d3ad122319882e8783101 Reviewed-on: https://skia-review.googlesource.com/50801 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r--samplecode/SampleApp.cpp29
-rw-r--r--samplecode/SampleApp.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index 6cb6785fc7..1c652ea0cb 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -7,6 +7,7 @@
#include "SampleApp.h"
+#include "SkCommonFlags.h"
#include "OverView.h"
#include "Resources.h"
#include "SampleCode.h"
@@ -757,6 +758,10 @@ DEFINE_pathrenderer_flag;
DEFINE_int32(msaa, 0, "Request multisampling with this count.");
DEFINE_bool(deepColor, false, "Request deep color (10-bit/channel or more) display buffer.");
#endif
+DEFINE_int32(backendTiles, 0, "Number of tiles in the experimental threaded backend.");
+DEFINE_int32(backendThreads, 0, "Number of threads in the experimental threaded backend.");
+DEFINE_int32(measureMS, 0, "Number of miliseconds to measure the FPS before closing the SampleApp. "
+ "If it's 0, we won't measure the FPS or close SampleApp automatically.");
#include "SkTaskGroup.h"
@@ -923,6 +928,22 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
fSaveToPdf = false;
fSaveToSKP = false;
+ gSkUseAnalyticAA = FLAGS_analyticAA;
+ gSkUseDeltaAA = FLAGS_deltaAA;
+ if (FLAGS_forceAnalyticAA) {
+ gSkForceAnalyticAA = true;
+ }
+ if (FLAGS_forceDeltaAA) {
+ gSkForceDeltaAA = true;
+ }
+ fTiles = FLAGS_backendTiles;
+ fThreads = FLAGS_backendThreads;
+ fMeasureMS = FLAGS_measureMS;
+ if (FLAGS_measureMS > 0) {
+ SkASSERT(fMeasureFPS == false);
+ toggleFPS();
+ }
+
if (true) {
fPipeSerializer.setTypefaceSerializer(new SampleTFSerializer);
fPipeDeserializer.setTypefaceDeserializer(new SampleTFDeserializer);
@@ -1042,6 +1063,10 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
}
SampleWindow::~SampleWindow() {
+ if (fMeasureFPS) {
+ SkDebugf("Average frame time of the last slide: %.4f ms\n",
+ fCumulativeFPS_Time / (float)SkTMax(1, fCumulativeFPS_Count));
+ }
SkSafeUnref(fDevManager);
}
@@ -2261,6 +2286,10 @@ bool SampleWindow::getRawTitle(SkString* title) {
}
void SampleWindow::updateTitle() {
+ if (fMeasureMS > 0 && (int)gAnimTimer.msec() > fMeasureMS) {
+ this->closeWindow();
+ }
+
SkString title;
if (!this->getRawTitle(&title)) {
title.set("<unknown>");
diff --git a/samplecode/SampleApp.h b/samplecode/SampleApp.h
index 52f041ac75..9f7b5dbd71 100644
--- a/samplecode/SampleApp.h
+++ b/samplecode/SampleApp.h
@@ -254,6 +254,8 @@ private:
int fThreads = 0;
std::unique_ptr<SkExecutor> fExecutor;
+ int fMeasureMS; // the number of milliseconds to measure the FPS before we close the SampleApp
+
void loadView(SkView*);
void updateTitle();
bool getRawTitle(SkString*);