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

Unified Diff: src/platform/microbenchmark/microbenchmark.h

Issue 492005: Overhaul microbenchmark so that it can be pulled in easily by any package (Closed)
Patch Set: fix cmasone's comments Created 11 years 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
« no previous file with comments | « src/platform/microbenchmark/make_pkg.sh ('k') | src/platform/microbenchmark/microbenchmark.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/microbenchmark/microbenchmark.h
diff --git a/src/platform/microbenchmark/microbenchmark.h b/src/platform/microbenchmark/microbenchmark.h
index ec4bf661927a7d516c3396aed956b4d5545eb08c..eb15cd6953dd2e3c8b0e5086f89385a3d90f8f8c 100644
--- a/src/platform/microbenchmark/microbenchmark.h
+++ b/src/platform/microbenchmark/microbenchmark.h
@@ -1,7 +1,6 @@
// Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// Some portions Copyright (c) 2009 The Chromium Authors.
//
// Simple microbenchmark framework
@@ -19,6 +18,22 @@
#include <base/scoped_ptr.h>
#include <gtest/gtest.h>
+// CHROMEOS_MICROBENCHMARK_WITH_SETUP is the primary macro for
+// using a microbenchmark from this framework.
+//
+// For quick use, create a new .cc file in your project.
+// Include this header and create two static functions,
+// one for setup and one for executing the test once.
+// After both are defined, append:
+// CHROMEOS_MICROBENCHMARK_WITH_SETUP(MySetup, MyTest, 100000)
+// The last argument is the default number of runs. This may
+// be overridden at run-time and, in the future, may be automatically
+// tweaked to avoid measurement errors.
+//
+// The _NAME function should be of the prototype:
+// void MyTest(bool scaffold_only);
+// The _SETUP_NAME function should be of the prototype:
+// void SetupMyTest(uint64 number_of_runs);
#define CHROMEOS_MICROBENCHMARK_WITH_SETUP(_SETUP_NAME, _NAME, _RUNS) \
class _NAME ## Class : public Microbenchmark { \
public: \
@@ -45,6 +60,8 @@ TEST(_NAME, Microbenchmark) { \
chromeos_benchmark.Print(); \
}
+// This is a shortcut macro. If you don't need to setup any global state for
+// use in your test, you can use this instead of _WITH_SETUP.
#define CHROMEOS_MICROBENCHMARK(_NAME, _RUNS) \
CHROMEOS_MICROBENCHMARK_WITH_SETUP(chromeos::microbenchmark_helper::NoSetup, \
_NAME, \
@@ -53,7 +70,7 @@ namespace chromeos {
namespace microbenchmark_helper {
void NoSetup(uint64 runs);
-} // microbenchmark
+} // microbenchmark_helper
// A simple microbenchmarking abstract class.
// This class is not thread-safe and should only be invoked
« no previous file with comments | « src/platform/microbenchmark/make_pkg.sh ('k') | src/platform/microbenchmark/microbenchmark.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698