Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
benchmark
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
benchmark
Commits
a94b0a67
Commit
a94b0a67
authored
Dec 19, 2013
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicated macros header
parent
9a25f472
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6 additions
and
114 deletions
+6
-114
cycleclock.h
src/cycleclock.h
+4
-2
macros.h
src/macros.h
+0
-110
sysinfo.cc
src/sysinfo.cc
+1
-1
walltime.cc
src/walltime.cc
+1
-1
No files found.
src/cycleclock.h
View file @
a94b0a67
...
@@ -39,15 +39,17 @@ extern "C" uint64_t __rdtsc();
...
@@ -39,15 +39,17 @@ extern "C" uint64_t __rdtsc();
#endif
#endif
#include <sys/time.h>
#include <sys/time.h>
#include "benchmark/macros.h"
namespace
benchmark
{
// NOTE: only i386 and x86_64 have been well tested.
// NOTE: only i386 and x86_64 have been well tested.
// PPC, sparc, alpha, and ia64 are based on
// PPC, sparc, alpha, and ia64 are based on
// http://peter.kuscsik.com/wordpress/?p=14
// http://peter.kuscsik.com/wordpress/?p=14
// with modifications by m3b. See also
// with modifications by m3b. See also
// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h
// https://setisvn.ssl.berkeley.edu/svn/lib/fftw-3.0.1/kernel/cycle.h
namespace
benchmark
{
namespace
cycleclock
{
namespace
cycleclock
{
// This should return the number of cycles since power-on. Thread-safe.
// This should return the number of cycles since power-on. Thread-safe.
static
inline
int64_t
Now
()
{
inline
ATTRIBUTE_ALWAYS_INLINE
int64_t
Now
()
{
#if defined(OS_MACOSX)
#if defined(OS_MACOSX)
// this goes at the top because we need ALL Macs, regardless of
// this goes at the top because we need ALL Macs, regardless of
// architecture, to return the number of "mach time units" that
// architecture, to return the number of "mach time units" that
...
...
src/macros.h
deleted
100644 → 0
View file @
9a25f472
#ifndef BENCHMARK_MACROS_H_
#define BENCHMARK_MACROS_H_
#include <assert.h>
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
TypeName(const TypeName&); \
void operator=(const TypeName&);
// The arraysize(arr) macro returns the # of elements in an array arr.
// The expression is a compile-time constant, and therefore can be
// used in defining new arrays, for example. If you use arraysize on
// a pointer by mistake, you will get a compile-time error.
//
// One caveat is that, for C++03, arraysize() doesn't accept any array of
// an anonymous type or a type defined inside a function. In these rare
// cases, you have to use the unsafe ARRAYSIZE() macro below. This is
// due to a limitation in C++03's template system. The limitation has
// been removed in C++11.
// This template function declaration is used in defining arraysize.
// Note that the function doesn't need an implementation, as we only
// use its type.
template
<
typename
T
,
size_t
N
>
char
(
&
ArraySizeHelper
(
T
(
&
array
)[
N
]))[
N
];
// That gcc wants both of these prototypes seems mysterious. VC, for
// its part, can't decide which to use (another mystery). Matching of
// template overloads: the final frontier.
#ifndef COMPILER_MSVC
template
<
typename
T
,
size_t
N
>
char
(
&
ArraySizeHelper
(
const
T
(
&
array
)[
N
]))[
N
];
#endif
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
// The STATIC_ASSERT macro can be used to verify that a compile time
// expression is true. For example, you could use it to verify the
// size of a static array:
//
// STATIC_ASSERT(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES,
// content_type_names_incorrect_size);
//
// or to make sure a struct is smaller than a certain size:
//
// STATIC_ASSERT(sizeof(foo) < 128, foo_too_large);
//
// The second argument to the macro is the name of the variable. If
// the expression is false, most compilers will issue a warning/error
// containing the name of the variable.
template
<
bool
>
struct
StaticAssert
{
};
#define STATIC_ASSERT(expr, msg) \
typedef StaticAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
// Implementation details of STATIC_ASSERT:
//
// - STATIC_ASSERT works by defining an array type that has -1
// elements (and thus is invalid) when the expression is false.
//
// - The simpler definition
//
// #define STATIC_ASSERT(expr, msg) typedef char msg[(expr) ? 1 : -1]
//
// does not work, as gcc supports variable-length arrays whose sizes
// are determined at run-time (this is gcc's extension and not part
// of the C++ standard). As a result, gcc fails to reject the
// following code with the simple definition:
//
// int foo;
// STATIC_ASSERT(foo, msg); // not supposed to compile as foo is
// // not a compile-time constant.
//
// - By using the type StaticAssert<(bool(expr))>, we ensures that
// expr is a compile-time constant. (Template arguments must be
// determined at compile-time.)
//
// - The outer parentheses in StaticAssert<(bool(expr))> are necessary
// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written
//
// StaticAssert<bool(expr)>
//
// instead, these compilers will refuse to compile
//
// STATIC_ASSERT(5 > 0, some_message);
//
// (They seem to think the ">" in "5 > 0" marks the end of the
// template argument list.)
//
// - The array size is (bool(expr) ? 1 : -1), instead of simply
//
// ((expr) ? 1 : -1).
//
// This is to avoid running into a bug in MS VC 7.1, which
// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1.
#define CHECK(b) do { if (!(b)) assert(false); } while(0)
#define CHECK_EQ(a, b) CHECK((a) == (b))
#define CHECK_GE(a, b) CHECK((a) >= (b))
#define CHECK_LE(a, b) CHECK((a) <= (b))
#define CHECK_GT(a, b) CHECK((a) > (b))
#define CHECK_LT(a, b) CHECK((a) < (b))
#define ATTRIBUTE_UNUSED __attribute__ ((unused))
#endif // BENCHMARK_MACROS_H_
src/sysinfo.cc
View file @
a94b0a67
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
#include <iostream>
#include <iostream>
#include <limits>
#include <limits>
#include "benchmark/macros.h"
#include "cycleclock.h"
#include "cycleclock.h"
#include "macros.h"
#include "mutex_lock.h"
#include "mutex_lock.h"
#include "sleep.h"
#include "sleep.h"
...
...
src/walltime.cc
View file @
a94b0a67
...
@@ -8,8 +8,8 @@
...
@@ -8,8 +8,8 @@
#include <atomic>
#include <atomic>
#include <limits>
#include <limits>
#include "benchmark/macros.h"
#include "cycleclock.h"
#include "cycleclock.h"
#include "macros.h"
#include "sysinfo.h"
#include "sysinfo.h"
namespace
benchmark
{
namespace
benchmark
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment