aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-04-22 06:25:17 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-04-22 07:31:52 -0700
commit9668b2981c32ebd804feed9970d7e95c8573e644 (patch)
tree7f5349d66de85015a29d6b33fe09250c5ff8efb4 /tensorflow/core
parente9db74626ea9e46a93eb0c15c37a2e138c83fade (diff)
Change tensorflow benchmark code to export results as serialized proto instead
of text proto. This simplifies ues of LITE_RUNTIME for mobile, where text functions are not available natively. Change: 120545368
Diffstat (limited to 'tensorflow/core')
-rw-r--r--tensorflow/core/util/reporter.cc10
-rw-r--r--tensorflow/core/util/reporter.h8
-rw-r--r--tensorflow/core/util/reporter_test.cc6
3 files changed, 11 insertions, 13 deletions
diff --git a/tensorflow/core/util/reporter.cc b/tensorflow/core/util/reporter.cc
index 1fe25afa66..ec5a5b6af7 100644
--- a/tensorflow/core/util/reporter.cc
+++ b/tensorflow/core/util/reporter.cc
@@ -27,15 +27,11 @@ TestReporter::TestReporter(const string& fname, const string& test_name)
Status TestReporter::Close() {
if (closed_) return Status::OK();
- string entry_string;
- if (!protobuf::TextFormat::PrintToString(benchmark_entry_, &entry_string)) {
- return errors::Internal("Could not serialize to string: ",
- benchmark_entry_.DebugString());
- }
+ BenchmarkEntries entries;
+ *entries.add_entry() = benchmark_entry_;
+ TF_RETURN_IF_ERROR(log_file_->Append(entries.SerializeAsString()));
- TF_RETURN_IF_ERROR(log_file_->Append(entry_string));
benchmark_entry_.Clear();
-
closed_ = true;
return log_file_->Close();
diff --git a/tensorflow/core/util/reporter.h b/tensorflow/core/util/reporter.h
index 6cfabc01ee..b8dc21a89d 100644
--- a/tensorflow/core/util/reporter.h
+++ b/tensorflow/core/util/reporter.h
@@ -29,8 +29,8 @@ limitations under the License.
namespace tensorflow {
-// The TestReporter writes test / benchmark output to text Protobuf files
-// when the environment variable "TEST_REPORT_FILE_PREFIX" is defined.
+// The TestReporter writes test / benchmark output to binary Protobuf files when
+// the environment variable "TEST_REPORT_FILE_PREFIX" is defined.
//
// If this environment variable is not defined, no logging is performed.
//
@@ -43,8 +43,8 @@ namespace tensorflow {
//
// For example, if the environment variable
// TEST_REPORT_FILE_PREFIX="/tmp/run_"
-// is set, and test_name is "BM_Foo/1/2", then a BenchmarkEntry pbtxt
-// is written to file:
+// is set, and test_name is "BM_Foo/1/2", then a BenchmarkEntries pb
+// with a single entry is written to file:
// /tmp/run_BM_Foo__1__2
//
class TestReporter {
diff --git a/tensorflow/core/util/reporter_test.cc b/tensorflow/core/util/reporter_test.cc
index acc4e5d477..d0eee3bd7d 100644
--- a/tensorflow/core/util/reporter_test.cc
+++ b/tensorflow/core/util/reporter_test.cc
@@ -103,8 +103,10 @@ TEST(TestReporter, Benchmark) {
string read;
TF_EXPECT_OK(ReadFileToString(Env::Default(), expected_fname, &read));
- BenchmarkEntry benchmark_entry;
- EXPECT_TRUE(protobuf::TextFormat::ParseFromString(read, &benchmark_entry));
+ BenchmarkEntries benchmark_entries;
+ ASSERT_TRUE(benchmark_entries.ParseFromString(read));
+ ASSERT_EQ(1, benchmark_entries.entry_size());
+ const BenchmarkEntry& benchmark_entry = benchmark_entries.entry(0);
EXPECT_EQ(benchmark_entry.name(), "b1/2/3");
EXPECT_EQ(benchmark_entry.iters(), 1);