Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(369)

Unified Diff: mojo/public/tests/test_support.cc

Issue 23621056: Initial in-process implementation of some Mojo primitives. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/tests/test_support.cc
diff --git a/mojo/public/tests/test_support.cc b/mojo/public/tests/test_support.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0140c9f6b76cbea7bdb17c3f85fa0136dece81d5
--- /dev/null
+++ b/mojo/public/tests/test_support.cc
@@ -0,0 +1,48 @@
+// Copyright 2013 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.
+
+#include "mojo/public/tests/test_support.h"
+
+#include "base/test/perf_log.h"
+#include "base/time/time.h"
+#include "mojo/system/core_impl.h"
+
+namespace mojo {
+namespace test {
+
+TestBase::TestBase() {
+}
+
+TestBase::~TestBase() {
+}
+
+void TestBase::SetUp() {
+ if (!system::CoreImpl::Get())
+ system::CoreImpl::Init();
+}
+
+void IterateAndReportPerf(const char* test_name,
+ base::Callback<void()> single_iteration) {
+ // TODO(vtl): These should be specifiable using command-line flags.
+ static const size_t kGranularity = 100;
+ static const double kPerftestTimeSeconds = 3.0;
+
+ const base::TimeTicks start_time = base::TimeTicks::HighResNow();
+ base::TimeTicks end_time;
+ size_t iterations = 0;
+ do {
+ for (size_t i = 0; i < kGranularity; i++)
+ single_iteration.Run();
+ iterations += kGranularity;
+
+ end_time = base::TimeTicks::HighResNow();
+ } while ((end_time - start_time).InSecondsF() < kPerftestTimeSeconds);
+
+ base::LogPerfResult(test_name,
+ iterations / (end_time - start_time).InSecondsF(),
+ "iterations/second");
+}
+
+} // namespace test
+} // namespace mojo
« mojo/mojo.gyp ('K') | « mojo/public/tests/test_support.h ('k') | mojo/system/core.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698