summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorpph34r@gmail.com <pph34r@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-16 07:29:17 +0000
committerpph34r@gmail.com <pph34r@gmail.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-16 07:29:17 +0000
commitb404b1f2399b7183f7ec54d42c7797ee54ffcd13 (patch)
treebcdc208cb4371b7f51cf000d5e7884e235e3703a /base
parenta73a6a4f6da13af6331d13c1f8ac624722072e0d (diff)
downloadchromium_src-b404b1f2399b7183f7ec54d42c7797ee54ffcd13.zip
chromium_src-b404b1f2399b7183f7ec54d42c7797ee54ffcd13.tar.gz
chromium_src-b404b1f2399b7183f7ec54d42c7797ee54ffcd13.tar.bz2
Fix of unused variable warnings related to DHISTOGRAM* in release builds.
Make DHISTOGRAM* keep a mention of passed variables. Add Histogram::DebugNow() for use in DHISTOGRAM* as a start_time. BUG=87490 TEST=None Review URL: http://codereview.chromium.org/8225001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105722 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/metrics/histogram.cc8
-rw-r--r--base/metrics/histogram.h50
2 files changed, 50 insertions, 8 deletions
diff --git a/base/metrics/histogram.cc b/base/metrics/histogram.cc
index dbd7278..8b11ee8 100644
--- a/base/metrics/histogram.cc
+++ b/base/metrics/histogram.cc
@@ -114,6 +114,14 @@ Histogram* Histogram::FactoryTimeGet(const std::string& name,
bucket_count, flags);
}
+TimeTicks Histogram::DebugNow() {
+#ifndef NDEBUG
+ return TimeTicks::Now();
+#else
+ return TimeTicks();
+#endif
+}
+
void Histogram::Add(int value) {
if (value > kSampleType_MAX - 1)
value = kSampleType_MAX - 1;
diff --git a/base/metrics/histogram.h b/base/metrics/histogram.h
index 401ece7..e8f6364 100644
--- a/base/metrics/histogram.h
+++ b/base/metrics/histogram.h
@@ -202,19 +202,50 @@ class Lock;
HISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges)
#else // NDEBUG
+// Keep a mention of passed variables to avoid unused variable warnings in
+// release build if these variables are only used in macros.
+#define DISCARD_2_ARGUMENTS(a, b) \
+ while (0) { \
+ static_cast<void>(a); \
+ static_cast<void>(b); \
+ }
+#define DISCARD_3_ARGUMENTS(a, b, c) \
+ while (0) { \
+ static_cast<void>(a); \
+ static_cast<void>(b); \
+ static_cast<void>(c); \
+ }
+#define DISCARD_5_ARGUMENTS(a, b, c, d ,e) \
+ while (0) { \
+ static_cast<void>(a); \
+ static_cast<void>(b); \
+ static_cast<void>(c); \
+ static_cast<void>(d); \
+ static_cast<void>(e); \
+ }
+#define DHISTOGRAM_TIMES(name, sample) \
+ DISCARD_2_ARGUMENTS(name, sample)
+
+#define DHISTOGRAM_COUNTS(name, sample) \
+ DISCARD_2_ARGUMENTS(name, sample)
+
+#define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) \
+ DISCARD_2_ARGUMENTS(name, under_one_hundred)
-#define DHISTOGRAM_TIMES(name, sample) do {} while (0)
-#define DHISTOGRAM_COUNTS(name, sample) do {} while (0)
-#define DHISTOGRAM_PERCENTAGE(name, under_one_hundred) do {} while (0)
#define DHISTOGRAM_CUSTOM_TIMES(name, sample, min, max, bucket_count) \
- do {} while (0)
+ DISCARD_5_ARGUMENTS(name, sample, min, max, bucket_count)
+
#define DHISTOGRAM_CLIPPED_TIMES(name, sample, min, max, bucket_count) \
- do {} while (0)
+ DISCARD_5_ARGUMENTS(name, sample, min, max, bucket_count)
+
#define DHISTOGRAM_CUSTOM_COUNTS(name, sample, min, max, bucket_count) \
- do {} while (0)
-#define DHISTOGRAM_ENUMERATION(name, sample, boundary_value) do {} while (0)
+ DISCARD_5_ARGUMENTS(name, sample, min, max, bucket_count)
+
+#define DHISTOGRAM_ENUMERATION(name, sample, boundary_value) \
+ DISCARD_3_ARGUMENTS(name, sample, boundary_value)
+
#define DHISTOGRAM_CUSTOM_ENUMERATION(name, sample, custom_ranges) \
- do {} while (0)
+ DISCARD_3_ARGUMENTS(name, sample, custom_ranges)
#endif // NDEBUG
@@ -409,6 +440,9 @@ class BASE_EXPORT Histogram {
base::TimeDelta maximum,
size_t bucket_count,
Flags flags);
+ // Time call for use with DHISTOGRAM*.
+ // Returns TimeTicks::Now() in debug and TimeTicks() in release build.
+ static TimeTicks DebugNow();
void Add(int value);