From: Mike Klein Date: Wed, 19 Oct 2016 17:27:07 +0000 (-0400) Subject: Make monobench more usable on Windows. X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~73^2~522 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4bc6d8fd3d0586444d743b07975a492cb6305448;p=platform%2Fupstream%2FlibSkiaSharp.git Make monobench more usable on Windows. All small stuff: - printf doesn't go to the Visual Studio console, SkDebugf does; - the Windows console can't show an ellipsis; - overwriting the console line is a little different on Windows. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3664 Change-Id: I0175afd6d0147feaff8ff6edae2b35a7435c25f5 Reviewed-on: https://skia-review.googlesource.com/3664 Reviewed-by: Mike Klein Commit-Queue: Mike Klein --- diff --git a/tools/monobench.cpp b/tools/monobench.cpp index a9dac37..d5c9611 100644 --- a/tools/monobench.cpp +++ b/tools/monobench.cpp @@ -6,17 +6,24 @@ */ #include "Benchmark.h" +#include "OverwriteLine.h" #include "SkGraphics.h" #include "SkTaskGroup.h" #include #include #include #include -#include #include #include #include + +#if defined(SK_BUILD_FOR_WIN32) +static const char* kEllipsis = "..."; +#else +static const char* kEllipsis = "…"; +#endif + int main(int argc, char** argv) { SkGraphics::Init(); SkTaskGroup::Enabler enabled; @@ -49,7 +56,7 @@ int main(int argc, char** argv) { } if (benches.size() == 0) { - printf("No bench matched.\n"); + SkDebugf("No bench matched.\n"); return 1; } @@ -64,7 +71,7 @@ int main(int argc, char** argv) { std::string prefix = benches[0].name.substr(0, common_prefix); if (common_prefix) { for (auto& bench : benches) { - bench.name.replace(0, common_prefix, "…"); + bench.name.replace(0, common_prefix, kEllipsis); } } @@ -78,11 +85,11 @@ int main(int argc, char** argv) { std::string suffix = benches[0].name.substr(benches[0].name.size() - common_suffix); if (common_suffix) { for (auto& bench : benches) { - bench.name.replace(bench.name.size() - common_suffix, common_suffix, "…"); + bench.name.replace(bench.name.size() - common_suffix, common_suffix, kEllipsis); } } - printf("%s…%s\n", prefix.c_str(), suffix.c_str()); + SkDebugf("%s%s%s\n", prefix.c_str(), kEllipsis, suffix.c_str()); } int samples = 0; @@ -106,15 +113,14 @@ int main(int argc, char** argv) { std::sort(benches.begin(), benches.end(), [](const Bench& a, const Bench& b) { return a.best < b.best; }); - printf("\r\033[K%d", samples); + SkDebugf("%s%d", kSkOverwriteLine, samples); for (auto& bench : benches) { if (benches.size() == 1) { - printf(" %s %gns" , bench.name.c_str(), bench.best.count()); + SkDebugf(" %s %gns" , bench.name.c_str(), bench.best.count()); } else { - printf(" %s %.3gx", bench.name.c_str(), bench.best / benches[0].best); + SkDebugf(" %s %.3gx", bench.name.c_str(), bench.best / benches[0].best); } } - fflush(stdout); break; } }