1349 {
1351
1353
1354#if defined(SK_BUILD_FOR_IOS)
1356#endif
1358 if (FLAGS_runtimeCPUDetection) {
1360 }
1361
1362
1365
1367
1369
1372
1374 FLAGS_samples = 1;
1375 FLAGS_gpuFrameLag = 0;
1376 }
1377
1378 if (!FLAGS_writePath.isEmpty()) {
1379 SkDebugf(
"Writing files to %s.\n", FLAGS_writePath[0]);
1380 if (!
sk_mkdir(FLAGS_writePath[0])) {
1381 SkDebugf(
"Could not create %s. Files won't be written.\n", FLAGS_writePath[0]);
1382 FLAGS_writePath.set(0, nullptr);
1383 }
1384 }
1385
1387 if (!FLAGS_outResultsFile.isEmpty()) {
1388#if defined(SK_RELEASE)
1389 logStream.reset(
new SkFILEWStream(FLAGS_outResultsFile[0]));
1390#else
1391 SkDebugf(
"I'm ignoring --outResultsFile because this is a Debug build.");
1392 return 1;
1393#endif
1394 }
1397
1398 if (1 == FLAGS_properties.size() % 2) {
1399 SkDebugf(
"ERROR: --properties must be passed with an even number of arguments.\n");
1400 return 1;
1401 }
1402 for (
int i = 1;
i < FLAGS_properties.size();
i += 2) {
1403 log.appendCString(FLAGS_properties[
i-1], FLAGS_properties[
i]);
1404 }
1405
1406 if (1 == FLAGS_key.size() % 2) {
1407 SkDebugf(
"ERROR: --key must be passed with an even number of arguments.\n");
1408 return 1;
1409 }
1410 if (FLAGS_key.size()) {
1411 log.beginObject(
"key");
1412 for (
int i = 1;
i < FLAGS_key.size();
i += 2) {
1413 log.appendCString(FLAGS_key[
i - 1], FLAGS_key[
i]);
1414 }
1416 }
1417
1419 if (!FLAGS_quiet && !FLAGS_csv) {
1421 }
1422
1424
1426 SkDebugf(
"Fixed number of loops; times would only be misleading so we won't print them.\n");
1427 } else if (FLAGS_quiet) {
1428 SkDebugf(
"! -> high variance, ? -> moderate variance\n");
1430 } else if (FLAGS_csv) {
1431 SkDebugf(
"min,median,mean,max,stddev,config,bench\n");
1432 } else if (FLAGS_ms) {
1433 SkDebugf(
"curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\tsamples\tconfig\tbench\n");
1434 } else {
1435 SkDebugf(
"curr/maxrss\tloops\tmin\tmedian\tmean\tmax\tstddev\t%-*s\tconfig\tbench\n",
1436 FLAGS_samples, "samples");
1437 }
1438
1440
1443
1444 if (FLAGS_keepAlive) {
1446 }
1447
1450
1451
1452
1453
1454
1455 log.beginObject(
"results");
1457
1458 int runs = 0;
1462 std::unique_ptr<Benchmark>
bench(
b);
1464 continue;
1465 }
1466
1469 bench->getUniqueName(),
bench->getSize().width(),
bench->getSize().height());
1470 bench->delayedSetup();
1471 }
1475 continue;
1476 }
1477
1478
1480 const char* config =
target->config.name.c_str();
1481
1482 if (FLAGS_pre_log || FLAGS_dryRun) {
1484 ,
bench->getUniqueName()
1485 , config);
1486 if (FLAGS_dryRun) {
1487 continue;
1488 }
1489 }
1490
1491 if (FLAGS_purgeBetweenBenches) {
1493 }
1494
1495 if (FLAGS_splitPerfettoTracesByBenchmark) {
1497 }
1500
1502 bench->perCanvasPreDraw(canvas);
1503
1504 int maxFrameLag;
1505 int loops =
target->needsFrameTiming(&maxFrameLag)
1508
1510
1512 continue;
1513 }
1514
1515 if (runs == 0 && FLAGS_ms < 1000) {
1516
1517
1518 auto stop =
now_ms() + 1000;
1519 do {
1522 }
while (
now_ms() < stop);
1523 }
1524
1525 if (FLAGS_ms) {
1527 auto stop =
now_ms() + FLAGS_ms;
1528 do {
1531 }
while (
now_ms() < stop);
1532 } else {
1533 samples.
reset(FLAGS_samples);
1534 for (
int s = 0;
s < FLAGS_samples;
s++) {
1537 }
1538 }
1539
1540
1541 for (double& sample : samples) {
1542 sample *= (1.0 /
bench->getUnits());
1543 }
1544
1548 if (FLAGS_gpuStatsDump) {
1549
1551 }
1554 dmsaaStats.dumpKeyValuePairs(&keys, &
values);
1555 dmsaaStats.dump();
1557 }
1558 }
1559
1560 bench->perCanvasPostDraw(canvas);
1561
1563 !FLAGS_writePath.isEmpty() && FLAGS_writePath[0]) {
1566 pngFilename.
append(
".png");
1568 }
1569
1570
1571
1572 const bool want_plot = !FLAGS_quiet && !FLAGS_ms;
1573
1575 log.beginObject(config);
1576
1577 log.beginObject(
"options");
1578 log.appendCString(
"name",
bench->getName());
1581
1582
1583 log.appendMetric(
"min_ms",
stats.min);
1585 log.beginArray(
"samples");
1586 for (double sample : samples) {
1587 log.appendDoubleDigits(sample, 16);
1588 }
1591 if (!keys.
empty()) {
1592
1594 for (
int j = 0; j < keys.
size(); j++) {
1595 log.appendMetric(keys[j].c_str(),
values[j]);
1596 }
1597 }
1598
1600
1601 if (runs++ % FLAGS_flushEvery == 0) {
1603 }
1604
1607 config = "";
1608 }
1612 ,
bench->getUniqueName()
1613 , config);
1615 } else if (FLAGS_quiet) {
1616 const char*
mark =
" ";
1617 const double stddev_percent =
1619 if (stddev_percent > 5)
mark =
"?";
1620 if (stddev_percent > 10)
mark =
"!";
1621
1624 } else if (FLAGS_csv) {
1625 const double stddev_percent =
1632 , stddev_percent
1633 , config
1634 ,
bench->getUniqueName()
1635 );
1636 } else {
1637 const double stddev_percent =
1639 SkDebugf(
"%4d/%-4dMB\t%d\t%s\t%s\t%s\t%s\t%.0f%%\t%s\t%s\t%s\n"
1642 , loops
1647 , stddev_percent
1649 , config
1650 ,
bench->getUniqueName()
1651 );
1652 }
1653
1656 }
1657
1658 if (FLAGS_verbose) {
1660 for (int j = 0; j < samples.size(); j++) {
1662 }
1664 }
1667 }
1670 }
1671 }
1672
1673 if (FLAGS_dmsaaStatsDump) {
1674 SkDebugf(
"<<Total Combined DMSAA Stats>>\n");
1676 }
1677
1679
1680 log.beginBench(
"memory_usage", 0, 0);
1681 log.beginObject(
"meta");
1685
1689
1690 return 0;
1691}
void initializeEventTracingForTools(const char *traceFlag)
GrRecordingContextPriv::DMSAAStats combinedDMSAAStats
static constexpr double sk_ieee_double_divide(double numer, double denom)
bool sk_mkdir(const char *path)
void RunSkSLModuleBenchmarks(NanoJSONResultsWriter *log)
#define TRACE_EVENT_API_NEW_TRACE_SECTION
#define TRACE_STR_COPY(str)
void fillCurrentOptions(NanoJSONResultsWriter &log) const
void fillCurrentMetrics(NanoJSONResultsWriter &log) const
static bool ShouldSkip(const SkTDArray< const char * > &strings, const char *name)
static void Parse(int argc, const char *const *argv)
GrRecordingContextPriv priv()
virtual GrRecordingContext * recordingContext() const
static void PurgeAllCaches()
void append(const char text[])
static void mark(SkCanvas *canvas, SkScalar x, SkScalar y, Fn &&fn)
void SetCtxOptions(struct GrContextOptions *)
void SK_API Register(Decoder d)
constexpr SkCodecs::Decoder Decoder()
constexpr SkCodecs::Decoder Decoder()
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
static Target * is_enabled(Benchmark *bench, const Config &config)
void create_configs(TArray< Config > *configs)
static void cleanup_run(Target *target)
static int setup_gpu_bench(Target *target, Benchmark *bench, int maxGpuFrameLag)
static bool write_canvas_png(Target *target, const SkString &filename)
static SkString to_string(int n)
static void start_keepalive()
static double time(int loops, Benchmark *bench, Target *target)
bool gForceHighPrecisionRasterPipeline
static double estimate_timer_overhead()
static int setup_cpu_bench(const double overhead, Target *target, Benchmark *bench)
bool gSkForceRasterPipelineBlitter
ShaderErrorHandler * fShaderErrorHandler
#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)