summaryrefslogtreecommitdiff
path: root/chromium/third_party/skia/bench/nanobench.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/bench/nanobench.cpp')
-rw-r--r--chromium/third_party/skia/bench/nanobench.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/chromium/third_party/skia/bench/nanobench.cpp b/chromium/third_party/skia/bench/nanobench.cpp
index be2acbc5e0a..05990f78a69 100644
--- a/chromium/third_party/skia/bench/nanobench.cpp
+++ b/chromium/third_party/skia/bench/nanobench.cpp
@@ -45,6 +45,7 @@
#include "tools/MSKPPlayer.h"
#include "tools/ProcStats.h"
#include "tools/Stats.h"
+#include "tools/ToolUtils.h"
#include "tools/flags/CommonFlags.h"
#include "tools/flags/CommonFlagsConfig.h"
#include "tools/ios_utils.h"
@@ -204,6 +205,10 @@ static DEFINE_string(properties, "",
static DEFINE_bool(purgeBetweenBenches, false,
"Call SkGraphics::PurgeAllCaches() between each benchmark?");
+static DEFINE_bool(splitPerfettoTracesByBenchmark, true,
+ "Create separate perfetto trace files for each benchmark?\n"
+ "Will only take effect if perfetto tracing is enabled. See --trace.");
+
static double now_ms() { return SkTime::GetNSecs() * 1e-6; }
static SkString humanize(double ms) {
@@ -351,7 +356,7 @@ struct GraphiteTarget : public Target {
this->testContext = testCtx;
this->context = ctx;
- this->recorder = this->context->makeRecorder();
+ this->recorder = this->context->makeRecorder(ToolUtils::CreateTestingRecorderOptions());
if (!this->recorder) {
return false;
}
@@ -1125,7 +1130,7 @@ public:
continue;
}
- while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(sampleSizes)) {
+ while (fCurrentSampleSize < (int) std::size(sampleSizes)) {
int sampleSize = sampleSizes[fCurrentSampleSize];
fCurrentSampleSize++;
if (10 * sampleSize > std::min(codec->getInfo().width(), codec->getInfo().height())) {
@@ -1165,7 +1170,7 @@ public:
}
while (fCurrentColorType < fColorTypes.count()) {
- while (fCurrentSampleSize < (int) SK_ARRAY_COUNT(brdSampleSizes)) {
+ while (fCurrentSampleSize < (int) std::size(brdSampleSizes)) {
while (fCurrentSubsetType <= kLastSingle_SubsetType) {
sk_sp<SkData> encoded(SkData::MakeFromFileName(path.c_str()));
@@ -1229,14 +1234,14 @@ public:
}
void fillCurrentOptions(NanoJSONResultsWriter& log) const {
- log.appendString("source_type", fSourceType);
- log.appendString("bench_type", fBenchType);
+ log.appendCString("source_type", fSourceType);
+ log.appendCString("bench_type", fBenchType);
if (0 == strcmp(fSourceType, "skp")) {
log.appendString("clip",
SkStringPrintf("%d %d %d %d", fClip.fLeft, fClip.fTop,
- fClip.fRight, fClip.fBottom).c_str());
+ fClip.fRight, fClip.fBottom));
SkASSERT_RELEASE(fCurrentScale < fScales.count()); // debugging paranoia
- log.appendString("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]).c_str());
+ log.appendString("scale", SkStringPrintf("%.2g", fScales[fCurrentScale]));
}
}
@@ -1371,7 +1376,7 @@ int main(int argc, char** argv) {
return 1;
}
for (int i = 1; i < FLAGS_properties.count(); i += 2) {
- log.appendString(FLAGS_properties[i-1], FLAGS_properties[i]);
+ log.appendCString(FLAGS_properties[i-1], FLAGS_properties[i]);
}
if (1 == FLAGS_key.count() % 2) {
@@ -1381,7 +1386,7 @@ int main(int argc, char** argv) {
if (FLAGS_key.count()) {
log.beginObject("key");
for (int i = 1; i < FLAGS_key.count(); i += 2) {
- log.appendString(FLAGS_key[i - 1], FLAGS_key[i]);
+ log.appendCString(FLAGS_key[i - 1], FLAGS_key[i]);
}
log.endObject(); // key
}
@@ -1461,6 +1466,9 @@ int main(int argc, char** argv) {
SkGraphics::PurgeAllCaches();
}
+ if (FLAGS_splitPerfettoTracesByBenchmark) {
+ TRACE_EVENT_API_NEW_TRACE_SECTION(TRACE_STR_COPY(bench->getUniqueName()));
+ }
TRACE_EVENT2("skia", "Benchmark", "name", TRACE_STR_COPY(bench->getUniqueName()),
"config", TRACE_STR_COPY(config));
@@ -1541,7 +1549,7 @@ int main(int argc, char** argv) {
log.beginObject(config);
log.beginObject("options");
- log.appendString("name", bench->getName());
+ log.appendCString("name", bench->getName());
benchStream.fillCurrentOptions(log);
log.endObject(); // options