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
80162cab
Commit
80162cab
authored
Dec 20, 2013
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update README.md
parent
01af2bc8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
3 deletions
+8
-3
README.md
README.md
+8
-3
No files found.
README.md
View file @
80162cab
...
@@ -3,13 +3,13 @@ benchmark
...
@@ -3,13 +3,13 @@ benchmark
A library to support the benchmarking of functions, similar to unit-tests.
A library to support the benchmarking of functions, similar to unit-tests.
Example usage:
Example usage:
// Define a function that executes the code to be measured a
Define a function that executes the code to be measured a
// specified number of times:
specified number of times:
static void BM_StringCreation(benchmark::State& state) {
static void BM_StringCreation(benchmark::State& state) {
while (state.KeepRunning())
while (state.KeepRunning())
std::string empty_string;
std::string empty_string;
}
}
// Register the function as a benchmark
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);
BENCHMARK(BM_StringCreation);
...
@@ -55,11 +55,13 @@ The preceding code is quite repetitive, and can be replaced with the
...
@@ -55,11 +55,13 @@ The preceding code is quite repetitive, and can be replaced with the
following short-hand. The following invocation will pick a few
following short-hand. The following invocation will pick a few
appropriate arguments in the specified range and will generate a
appropriate arguments in the specified range and will generate a
microbenchmark for each such argument.
microbenchmark for each such argument.
BENCHMARK(BM_memcpy)->Range(8, 8<<10);
BENCHMARK(BM_memcpy)->Range(8, 8<<10);
You might have a microbenchmark that depends on two inputs. For
You might have a microbenchmark that depends on two inputs. For
example, the following code defines a family of microbenchmarks for
example, the following code defines a family of microbenchmarks for
measuring the speed of set insertion.
measuring the speed of set insertion.
static void BM_SetInsert(benchmark::State& state) {
static void BM_SetInsert(benchmark::State& state) {
while (state.KeepRunning()) {
while (state.KeepRunning()) {
state.PauseTiming();
state.PauseTiming();
...
@@ -83,6 +85,7 @@ The preceding code is quite repetitive, and can be replaced with
...
@@ -83,6 +85,7 @@ The preceding code is quite repetitive, and can be replaced with
the following short-hand. The following macro will pick a few
the following short-hand. The following macro will pick a few
appropriate arguments in the product of the two specified ranges
appropriate arguments in the product of the two specified ranges
and will generate a microbenchmark for each such pair.
and will generate a microbenchmark for each such pair.
BENCHMARK(BM_SetInsert)->RangePair(1<<10, 8<<10, 1, 512);
BENCHMARK(BM_SetInsert)->RangePair(1<<10, 8<<10, 1, 512);
For more complex patterns of inputs, passing a custom function
For more complex patterns of inputs, passing a custom function
...
@@ -90,6 +93,7 @@ to Apply allows programmatic specification of an
...
@@ -90,6 +93,7 @@ to Apply allows programmatic specification of an
arbitrary set of arguments to run the microbenchmark on.
arbitrary set of arguments to run the microbenchmark on.
The following example enumerates a dense range on one parameter,
The following example enumerates a dense range on one parameter,
and a sparse range on the second.
and a sparse range on the second.
static benchmark::internal::Benchmark* CustomArguments(
static benchmark::internal::Benchmark* CustomArguments(
benchmark::internal::Benchmark* b) {
benchmark::internal::Benchmark* b) {
for (int i = 0; i <= 10; ++i)
for (int i = 0; i <= 10; ++i)
...
@@ -102,6 +106,7 @@ and a sparse range on the second.
...
@@ -102,6 +106,7 @@ and a sparse range on the second.
Templated microbenchmarks work the same way:
Templated microbenchmarks work the same way:
Produce then consume 'size' messages 'iters' times
Produce then consume 'size' messages 'iters' times
Measures throughput in the absence of multiprogramming.
Measures throughput in the absence of multiprogramming.
template <class Q> int BM_Sequential(benchmark::State& state) {
template <class Q> int BM_Sequential(benchmark::State& state) {
Q q;
Q q;
typename Q::value_type v;
typename Q::value_type v;
...
...
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