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
240ba4e6
Commit
240ba4e6
authored
Jun 02, 2016
by
Ismael
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changed BigOFunc argument from size_t to int
parent
f9644800
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
11 deletions
+11
-11
README.md
README.md
+1
-1
benchmark_api.h
include/benchmark/benchmark_api.h
+1
-1
complexity.cc
src/complexity.cc
+6
-6
complexity_test.cc
test/complexity_test.cc
+3
-3
No files found.
README.md
View file @
240ba4e6
...
@@ -147,7 +147,7 @@ that might be used to customize high-order term calculation.
...
@@ -147,7 +147,7 @@ that might be used to customize high-order term calculation.
```
c++
```
c++
BENCHMARK
(
BM_StringCompare
)
->
RangeMultiplier
(
2
)
BENCHMARK
(
BM_StringCompare
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
18
)
->
Complexity
([](
size_
t
n
)
->
double
{
return
n
;
});
->
Range
(
1
<<
10
,
1
<<
18
)
->
Complexity
([](
in
t
n
)
->
double
{
return
n
;
});
```
```
### Templated benchmarks
### Templated benchmarks
...
...
include/benchmark/benchmark_api.h
View file @
240ba4e6
...
@@ -253,7 +253,7 @@ enum BigO {
...
@@ -253,7 +253,7 @@ enum BigO {
// BigOFunc is passed to a benchmark in order to specify the asymptotic
// BigOFunc is passed to a benchmark in order to specify the asymptotic
// computational complexity for the benchmark.
// computational complexity for the benchmark.
typedef
double
(
BigOFunc
)(
size_
t
);
typedef
double
(
BigOFunc
)(
in
t
);
// State is passed to a running Benchmark and contains state for the
// State is passed to a running Benchmark and contains state for the
// benchmark to use.
// benchmark to use.
...
...
src/complexity.cc
View file @
240ba4e6
...
@@ -29,18 +29,18 @@ namespace benchmark {
...
@@ -29,18 +29,18 @@ namespace benchmark {
BigOFunc
*
FittingCurve
(
BigO
complexity
)
{
BigOFunc
*
FittingCurve
(
BigO
complexity
)
{
switch
(
complexity
)
{
switch
(
complexity
)
{
case
oN
:
case
oN
:
return
[](
size_
t
n
)
->
double
{
return
n
;
};
return
[](
in
t
n
)
->
double
{
return
n
;
};
case
oNSquared
:
case
oNSquared
:
return
[](
size_
t
n
)
->
double
{
return
n
*
n
;
};
return
[](
in
t
n
)
->
double
{
return
n
*
n
;
};
case
oNCubed
:
case
oNCubed
:
return
[](
size_
t
n
)
->
double
{
return
n
*
n
*
n
;
};
return
[](
in
t
n
)
->
double
{
return
n
*
n
*
n
;
};
case
oLogN
:
case
oLogN
:
return
[](
size_
t
n
)
{
return
log2
(
n
);
};
return
[](
in
t
n
)
{
return
log2
(
n
);
};
case
oNLogN
:
case
oNLogN
:
return
[](
size_
t
n
)
{
return
n
*
log2
(
n
);
};
return
[](
in
t
n
)
{
return
n
*
log2
(
n
);
};
case
o1
:
case
o1
:
default
:
default
:
return
[](
size_
t
)
{
return
1.0
;
};
return
[](
in
t
)
{
return
1.0
;
};
}
}
}
}
...
...
test/complexity_test.cc
View file @
240ba4e6
...
@@ -154,7 +154,7 @@ void BM_Complexity_O1(benchmark::State& state) {
...
@@ -154,7 +154,7 @@ void BM_Complexity_O1(benchmark::State& state) {
state
.
SetComplexityN
(
state
.
range_x
());
state
.
SetComplexityN
(
state
.
range_x
());
}
}
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
(
benchmark
::
o1
);
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
(
benchmark
::
o1
);
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
([](
size_
t
){
return
1.0
;
});
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
([](
in
t
){
return
1.0
;
});
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
();
BENCHMARK
(
BM_Complexity_O1
)
->
Range
(
1
,
1
<<
18
)
->
Complexity
();
std
::
string
big_o_1_test_name
=
"BM_Complexity_O1_BigO"
;
std
::
string
big_o_1_test_name
=
"BM_Complexity_O1_BigO"
;
...
@@ -192,7 +192,7 @@ void BM_Complexity_O_N(benchmark::State& state) {
...
@@ -192,7 +192,7 @@ void BM_Complexity_O_N(benchmark::State& state) {
state
.
SetComplexityN
(
state
.
range_x
());
state
.
SetComplexityN
(
state
.
range_x
());
}
}
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
(
benchmark
::
oN
);
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
(
benchmark
::
oN
);
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
([](
size_
t
n
)
->
double
{
return
n
;
});
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
([](
in
t
n
)
->
double
{
return
n
;
});
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
();
BENCHMARK
(
BM_Complexity_O_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
();
std
::
string
big_o_n_test_name
=
"BM_Complexity_O_N_BigO"
;
std
::
string
big_o_n_test_name
=
"BM_Complexity_O_N_BigO"
;
...
@@ -220,7 +220,7 @@ static void BM_Complexity_O_N_log_N(benchmark::State& state) {
...
@@ -220,7 +220,7 @@ static void BM_Complexity_O_N_log_N(benchmark::State& state) {
state
.
SetComplexityN
(
state
.
range_x
());
state
.
SetComplexityN
(
state
.
range_x
());
}
}
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
(
benchmark
::
oNLogN
);
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
(
benchmark
::
oNLogN
);
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
([](
size_
t
n
)
{
return
n
*
log2
(
n
);
});
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
([](
in
t
n
)
{
return
n
*
log2
(
n
);
});
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
();
BENCHMARK
(
BM_Complexity_O_N_log_N
)
->
RangeMultiplier
(
2
)
->
Range
(
1
<<
10
,
1
<<
16
)
->
Complexity
();
std
::
string
big_o_n_lg_n_test_name
=
"BM_Complexity_O_N_log_N_BigO"
;
std
::
string
big_o_n_lg_n_test_name
=
"BM_Complexity_O_N_log_N_BigO"
;
...
...
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