Commit 3ddcfb71 authored by calamity's avatar calamity Committed by Commit Bot

Revert "[image_decode_bench] Use //base CommandLine to process arguments"

This reverts commit 18ff8e77.

Reason for revert: Breaking win32-rel compile
https://ci.chromium.org/p/chromium/builders/luci.chromium.ci/win32-rel/10878

Original change's description:
> [image_decode_bench] Use //base CommandLine to process arguments
> 
>  - use //base CommandLine to process the command line arguments
>  - add support for benching multiple input image files
>  - include the input file file name in the output
>  - add program usage and help arguments -h --help
>  - retain the -i iterations option for now
>  - remove an old TODO
> 
> Bug: 601198
> Change-Id: Ib4e942dcc89ef9ff7eda6271f0cb3d0f93c5cca1
> Reviewed-on: https://chromium-review.googlesource.com/c/1454104
> Reviewed-by: Leon Scroggins <scroggo@chromium.org>
> Commit-Queue: Noel Gordon <noel@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#630123}

TBR=scroggo@chromium.org,noel@chromium.org,adenilson.cavalcanti@arm.com

Change-Id: Ic3aadcb231ceccbbe11a1b591de655a33f8d696e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 601198
Reviewed-on: https://chromium-review.googlesource.com/c/1459869Reviewed-by: default avatarcalamity <calamity@chromium.org>
Commit-Queue: calamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#630124}
parent 18ff8e77
...@@ -4,7 +4,13 @@ ...@@ -4,7 +4,13 @@
// Provides a minimal wrapping of the Blink image decoders. Used to perform // Provides a minimal wrapping of the Blink image decoders. Used to perform
// a non-threaded, memory-to-memory image decode using micro second accuracy // a non-threaded, memory-to-memory image decode using micro second accuracy
// clocks to measure image decode time. // clocks to measure image decode time. Basic usage:
//
// % ninja -C out/Release image_decode_bench &&
// ./out/Release/image_decode_bench file [iterations]
//
// TODO(noel): Consider adding md5 checksum support to WTF. Use it to compute
// the decoded image frame md5 and output that value.
// //
// TODO(noel): Consider integrating this tool in Chrome telemetry for realz, // TODO(noel): Consider integrating this tool in Chrome telemetry for realz,
// using the image corpora used to assess Blink image decode performance. See // using the image corpora used to assess Blink image decode performance. See
...@@ -76,75 +82,55 @@ void DecodeImageData(SharedBuffer* data, ImageMeta* image) { ...@@ -76,75 +82,55 @@ void DecodeImageData(SharedBuffer* data, ImageMeta* image) {
image->frames = frame_count; image->frames = frame_count;
} }
const char* program = nullptr;
base::CommandLine* CommandLineInitialize(int argc, char* argv[]) {
program = argv[0];
CHECK(base::CommandLine::Init(argc, argv));
return base::CommandLine::ForCurrentProcess();
}
void ShowUsageAndExit() {
fprintf(stderr, "Usage: %s [-i=iterations] file [file...]\n", program);
exit(1);
}
bool CommandLineHelp(const base::CommandLine* command_line) {
return command_line->HasSwitch("help") || command_line->HasSwitch("h");
}
unsigned CommandLineIterations(const base::CommandLine* command_line) {
if (!command_line->HasSwitch("i"))
return 1;
int iterations = atoi(command_line->GetSwitchValueASCII("i").c_str());
if (iterations >= 1)
return unsigned(iterations);
ShowUsageAndExit();
return 0;
}
} // namespace } // namespace
int ImageDecodeBenchMain(int argc, char* argv[]) { int ImageDecodeBenchMain(int argc, char* argv[]) {
base::CommandLine* command_line = CommandLineInitialize(argc, argv); base::CommandLine::Init(argc, argv);
const char* program = argv[0];
if (CommandLineHelp(command_line) || !command_line->GetArgs().size())
ShowUsageAndExit();
const unsigned iterations = CommandLineIterations(command_line); if (argc < 2) {
fprintf(stderr, "Usage: %s file [iterations]\n", program);
exit(1);
}
// Setup Blink platform. // Control bench decode iterations.
size_t decode_iterations = 1;
if (argc >= 3) {
char* end = nullptr;
decode_iterations = strtol(argv[2], &end, 10);
if (*end != '\0' || !decode_iterations) {
fprintf(stderr,
"Second argument should be number of iterations. "
"The default is 1. You supplied %s\n",
argv[2]);
exit(1);
}
}
std::unique_ptr<Platform> platform = std::make_unique<Platform>(); std::unique_ptr<Platform> platform = std::make_unique<Platform>();
Platform::CreateMainThreadAndInitialize(platform.get()); Platform::CreateMainThreadAndInitialize(platform.get());
// Bench each image file. // Read entire file content into |data| (a contiguous block of memory) then
// decode it to verify the image and record its ImageMeta data.
for (const auto& file : command_line->GetArgs()) { ImageMeta image = {argv[1], 0, 0, 0, 0};
const char* name = file.c_str(); scoped_refptr<SharedBuffer> data = ReadFile(argv[1]);
DecodeImageData(data.get(), &image);
// Read entire file content into |data| (a contiguous block of memory) then // Image decode bench for decode_iterations.
// decode it to verify the image and record its ImageMeta data.
ImageMeta image = {name, 0, 0, 0, 0}; double total_time = 0.0;
scoped_refptr<SharedBuffer> data = ReadFile(name); for (size_t i = 0; i < decode_iterations; ++i) {
image.time = 0.0;
DecodeImageData(data.get(), &image); DecodeImageData(data.get(), &image);
total_time += image.time;
// Image decode bench for iterations.
double total_time = 0.0;
for (unsigned i = 0; i < iterations; ++i) {
image.time = 0.0;
DecodeImageData(data.get(), &image);
total_time += image.time;
}
// Results to stdout.
double average_time = total_time / iterations;
printf("%f %f %s\n", total_time, average_time, name);
} }
// Results to stdout.
double average_time = total_time / decode_iterations;
printf("%f %f\n", total_time, average_time);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment