16645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org/*
26645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org * Copyright 2013 Google Inc.
36645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org *
46645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be
56645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org * found in the LICENSE file.
66645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org */
76645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
89ac68ee2594f28dfc1bd16a4bf004b1a4f6f228dmtklein#include "Timer.h"
9f168b86d7fafc5c20c87bebc6fd393cb17e120catfarina#include "Benchmark.h"
106645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "LazyDecodeBitmap.h"
116645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "PictureBenchmark.h"
126645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "PictureRenderer.h"
13f168b86d7fafc5c20c87bebc6fd393cb17e120catfarina#include "SkCommandLineFlags.h"
146645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "SkForceLinking.h"
156645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "SkGraphics.h"
166645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "SkStream.h"
176645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org#include "SkString.h"
1849a07ad0977fb118fe91f5c908b6703e2d89dec6commit-bot@chromium.org#include "SkTArray.h"
196645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
20cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgtypedef sk_tools::PictureRenderer::BBoxHierarchyType BBoxType;
21cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgstatic const int kBBoxTypeCount = sk_tools::PictureRenderer::kLast_BBoxHierarchyType + 1;
226645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
236645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
24cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgDEFINE_string2(skps, r, "", "The list of SKPs to benchmark.");
25f16d797497aff698e4dfcef0885dce04915a8c36commit-bot@chromium.orgDEFINE_string(bb_types, "", "The set of bbox types to test. If empty, all are tested. "
26cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                       "Should be one or more of none, quadtree, rtree, tilegrid.");
27cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgDEFINE_int32(record, 100, "Number of times to record each SKP.");
28cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgDEFINE_int32(playback, 1, "Number of times to playback each SKP.");
29cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgDEFINE_int32(tilesize, 256, "The size of a tile.");
302e915b32347aa2c2bcf82aba57c325b8fb81ec53commit-bot@chromium.org
31cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgstruct Measurement {
326645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkString fName;
33cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    double fRecordAverage[kBBoxTypeCount];
34cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    double fPlaybackAverage[kBBoxTypeCount];
356645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org};
366645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
37cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.orgconst char* kBBoxHierarchyTypeNames[kBBoxTypeCount] = {
38cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    "none", // kNone_BBoxHierarchyType
39cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    "quadtree", // kQuadTree_BBoxHierarchyType
40cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    "rtree", // kRTree_BBoxHierarchyType
41cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    "tilegrid", // kTileGrid_BBoxHierarchyType
426645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org};
436645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
446645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgstatic SkPicture* pic_from_path(const char path[]) {
456645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkFILEStream stream(path);
466645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    if (!stream.isValid()) {
476645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        SkDebugf("-- Can't open '%s'\n", path);
486645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        return NULL;
496645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
506645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    return SkPicture::CreateFromStream(&stream, &sk_tools::LazyDecodeBitmap);
516645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org}
526645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
536645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org/**
546645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org * This function is the sink to which all work ends up going.
55cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org * @param renderer The renderer to use to perform the work.
56cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org *                 To measure rendering, use a TiledPictureRenderer.
57cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org *                 To measure recording, use a RecordPictureRenderer.
58cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org * @param bBoxType The bounding box hierarchy type to use.
59cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org * @param pic The picture to draw to the renderer.
60cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org * @param numRepeats The number of times to repeat the draw.
61cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org * @param timer The timer used to benchmark the work.
626645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org */
636645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgstatic void do_benchmark_work(sk_tools::PictureRenderer* renderer,
64cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        BBoxType bBoxType,
65cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        SkPicture* pic,
66cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        const int numRepeats,
679ac68ee2594f28dfc1bd16a4bf004b1a4f6f228dmtklein        Timer* timer) {
68cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    renderer->setBBoxHierarchyType(bBoxType);
69cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    renderer->setGridSize(FLAGS_tilesize, FLAGS_tilesize);
703f0451772109959fcb79bacf2c9a03e0eb39ff27commit-bot@chromium.org    renderer->init(pic, NULL, NULL, NULL, false);
716645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
72cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    SkDebugf("%s %d times...\n", renderer->getConfigName().c_str(), numRepeats);
736645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    for (int i = 0; i < numRepeats; ++i) {
746645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        renderer->setup();
75cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        // Render once to fill caches
76f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org        renderer->render();
776645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        // Render again to measure
786645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        timer->start();
79f5e315ccf1ae2941f7cf53fa53e5c8c4bb665fe1commit-bot@chromium.org        renderer->render();
806645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        timer->end();
816645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
826645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org}
836645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
841d38ae9162d9702a8999e1fe872ead3e0a3f1181sglez@google.comint tool_main(int argc, char** argv);
851d38ae9162d9702a8999e1fe872ead3e0a3f1181sglez@google.comint tool_main(int argc, char** argv) {
86cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    SkCommandLineFlags::Parse(argc, argv);
876645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkAutoGraphics ag;
88cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    bool includeBBoxType[kBBoxTypeCount];
89cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) {
90f16d797497aff698e4dfcef0885dce04915a8c36commit-bot@chromium.org        includeBBoxType[bBoxType] = (FLAGS_bb_types.count() == 0) ||
91f16d797497aff698e4dfcef0885dce04915a8c36commit-bot@chromium.org            FLAGS_bb_types.contains(kBBoxHierarchyTypeNames[bBoxType]);
92cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    }
93cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    // go through all the pictures
94cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    SkTArray<Measurement> measurements;
95cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    for (int index = 0; index < FLAGS_skps.count(); ++index) {
96cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        const char* path = FLAGS_skps[index];
97cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        SkPicture* picture = pic_from_path(path);
98cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        if (NULL == picture) {
99cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            SkDebugf("Couldn't create picture. Ignoring path: %s\n", path);
100cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            continue;
101cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        }
102cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        SkDebugf("Benchmarking path: %s\n", path);
103cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        Measurement& measurement = measurements.push_back();
104cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        measurement.fName = path;
105cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) {
106cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            if (!includeBBoxType[bBoxType]) { continue; }
107cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            if (FLAGS_playback > 0) {
108cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                sk_tools::TiledPictureRenderer playbackRenderer;
1099ac68ee2594f28dfc1bd16a4bf004b1a4f6f228dmtklein                Timer playbackTimer;
110cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                do_benchmark_work(&playbackRenderer, (BBoxType)bBoxType,
111cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                                  picture, FLAGS_playback, &playbackTimer);
112cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                measurement.fPlaybackAverage[bBoxType] = playbackTimer.fCpu;
113cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            }
114cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            if (FLAGS_record > 0) {
115cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                sk_tools::RecordPictureRenderer recordRenderer;
1169ac68ee2594f28dfc1bd16a4bf004b1a4f6f228dmtklein                Timer recordTimer;
117cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                do_benchmark_work(&recordRenderer, (BBoxType)bBoxType,
118cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                                  picture, FLAGS_record, &recordTimer);
119cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                measurement.fRecordAverage[bBoxType] = recordTimer.fCpu;
120cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            }
121cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        }
1226645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
1236645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
124cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    Measurement globalMeasurement;
125cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) {
126cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        if (!includeBBoxType[bBoxType]) { continue; }
127cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        globalMeasurement.fPlaybackAverage[bBoxType] = 0;
128cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        globalMeasurement.fRecordAverage[bBoxType] = 0;
129cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        for (int index = 0; index < measurements.count(); ++index) {
130cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            const Measurement& measurement = measurements[index];
131cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            globalMeasurement.fPlaybackAverage[bBoxType] +=
132cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                measurement.fPlaybackAverage[bBoxType];
133cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            globalMeasurement.fRecordAverage[bBoxType] +=
134cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                measurement.fRecordAverage[bBoxType];
135cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        }
136cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        globalMeasurement.fPlaybackAverage[bBoxType] /= measurements.count();
137cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        globalMeasurement.fRecordAverage[bBoxType] /= measurements.count();
1386645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
1396645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1406645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    // Output gnuplot readable histogram data..
1416645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    const char* pbTitle = "bbh_shootout_playback.dat";
1426645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    const char* recTitle = "bbh_shootout_record.dat";
1436645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkFILEWStream playbackOut(pbTitle);
1446645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkFILEWStream recordOut(recTitle);
1456645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    recordOut.writeText("# ");
1466645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    playbackOut.writeText("# ");
147cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    SkDebugf("---\n");
148cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) {
149cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        if (!includeBBoxType[bBoxType]) { continue; }
1506645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        SkString out;
151cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        out.printf("%s ", kBBoxHierarchyTypeNames[bBoxType]);
152cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        recordOut.writeText(out.c_str());
153cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        playbackOut.writeText(out.c_str());
154cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org
155cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        if (FLAGS_record > 0) {
156cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            SkDebugf("Average %s recording time: %.3fms\n",
157cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                kBBoxHierarchyTypeNames[bBoxType],
158cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                globalMeasurement.fRecordAverage[bBoxType]);
1596645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        }
160cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        if (FLAGS_playback > 0) {
161cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            SkDebugf("Average %s playback time: %.3fms\n",
162cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                kBBoxHierarchyTypeNames[bBoxType],
163cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org                globalMeasurement.fPlaybackAverage[bBoxType]);
1646645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        }
1656645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
1666645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    recordOut.writeText("\n");
1676645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    playbackOut.writeText("\n");
1682e915b32347aa2c2bcf82aba57c325b8fb81ec53commit-bot@chromium.org    // Write to file, and save recording averages.
169cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org    for (int index = 0; index < measurements.count(); ++index) {
170cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        const Measurement& measurement = measurements[index];
1716645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        SkString pbLine;
1726645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        SkString recLine;
1736645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
174cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        pbLine.printf("%d", index);
175cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        recLine.printf("%d", index);
176cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org        for (int bBoxType = 0; bBoxType < kBBoxTypeCount; ++bBoxType) {
177cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            if (!includeBBoxType[bBoxType]) { continue; }
178cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            pbLine.appendf(" %f", measurement.fPlaybackAverage[bBoxType]);
179cdd0f92b1aca0c2164ac1a24d7f14a6ad3cc10f5commit-bot@chromium.org            recLine.appendf(" %f", measurement.fRecordAverage[bBoxType]);
1806645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        }
1816645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        pbLine.appendf("\n");
1826645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        recLine.appendf("\n");
1836645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        playbackOut.writeText(pbLine.c_str());
1846645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org        recordOut.writeText(recLine.c_str());
1856645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    }
1866645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    SkDebugf("\nWrote data to gnuplot-readable files: %s %s\n", pbTitle, recTitle);
1876645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    return 0;
1886645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org}
1896645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org
1905f3f681db58d613f5b96caa0af45ba15f776fe96sglez@google.com#if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1916645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.orgint main(int argc, char** argv) {
1926645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org    return tool_main(argc, argv);
1936645cde43d7dbf0df76dbda2c089d8f58560e3e2commit-bot@chromium.org}
1945f3f681db58d613f5b96caa0af45ba15f776fe96sglez@google.com#endif
195