Commit 19737e9f authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Revert "Add a json_perftest_decodebench program"

This reverts commit d1c2a486.

Reason for revert: caused compilation failure:
https://ci.chromium.org/p/chromium/builders/ci/win32-archive-rel/12506?

Original change's description:
> Add a json_perftest_decodebench program
> 
> The existing //base/json/json_perftest.cc, run automatically as part of
> continuous integration, benchmarks synthetic JSON data. This program,
> run manually, benchmarks real data (e.g. from a web crawl, passed as
> command line arguments). Both are useful.
> 
> Bug: 1069271
> Change-Id: I61f519804d731895e804d86f893c857cc1ac5953
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2154626
> Commit-Queue: Nigel Tao <nigeltao@chromium.org>
> Reviewed-by: Robert Sesek <rsesek@chromium.org>
> Reviewed-by: Nico Weber <thakis@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#762683}

TBR=thakis@chromium.org,rsesek@chromium.org,nigeltao@chromium.org

Change-Id: Id6b89d0a2aede5c454753b622ca05d69681225e0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1069271
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2167106Reviewed-by: default avatarXida Chen <xidachen@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#762684}
parent d1c2a486
......@@ -2362,11 +2362,6 @@ if (!is_ios) {
"//build/win:default_exe_manifest",
]
}
executable("json_perftest_decodebench") {
sources = [ "json/json_perftest_decodebench.cc" ]
deps = [ ":base" ]
}
}
if (is_win) {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This program measures the time taken to decode the given JSON files (the
// command line arguments). It is for manual benchmarking.
//
// Usage:
// $ ninja -C out/foobar json_perftest_decodebench
// $ out/foobar/json_perftest_decodebench -a -n=10 the/path/to/your/*.json
//
// The -n=10 switch controls the number of iterations. It defaults to 1.
//
// The -a switch means to print 1 non-comment line per input file (the average
// iteration time). Without this switch (the default), it prints n non-comment
// lines per input file (individual iteration times). For a single input file,
// building and running this program before and after a particular commit can
// work well with the 'ministat' tool: https://github.com/thorduri/ministat
#include <inttypes.h>
#include <stdio.h>
#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/json/json_reader.h"
#include "base/time/time.h"
int main(int argc, char* argv[]) {
if (!base::ThreadTicks::IsSupported()) {
printf("# base::ThreadTicks is not supported\n");
return EXIT_FAILURE;
}
base::ThreadTicks::WaitUntilInitialized();
base::CommandLine command_line(argc, argv);
bool average = command_line.HasSwitch("a");
int iterations = 1;
std::string iterations_str = command_line.GetSwitchValueASCII("n");
if (!iterations_str.empty()) {
iterations = atoi(iterations_str.c_str());
if (iterations < 1) {
printf("# invalid -n command line switch\n");
return EXIT_FAILURE;
}
}
if (average) {
printf("# Microseconds (μs), n=%d, averaged\n", iterations);
} else {
printf("# Microseconds (μs), n=%d\n", iterations);
}
for (const auto& filename : command_line.GetArgs()) {
std::string src;
if (!base::ReadFileToString(base::FilePath(filename), &src)) {
printf("# could not read %s\n", filename.c_str());
return EXIT_FAILURE;
}
int64_t total_time = 0;
for (int i = 0; i < iterations; ++i) {
auto start = base::ThreadTicks::Now();
auto v = base::JSONReader::ReadAndReturnValueWithError(src);
auto end = base::ThreadTicks::Now();
int64_t iteration_time = (end - start).InMicroseconds();
total_time += iteration_time;
if (i == 0) {
if (!v.error_message.empty()) {
printf("# %s: %s\n", filename.c_str(), v.error_message.c_str());
} else if (!average) {
printf("# %s\n", filename.c_str());
}
}
if (!average) {
printf("%" PRId64 "\n", iteration_time);
}
}
if (average) {
int64_t average_time = total_time / iterations;
printf("%12" PRId64 "\t# %s\n", average_time, filename.c_str());
}
}
return EXIT_SUCCESS;
}
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