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
66bf7c8f
Commit
66bf7c8f
authored
Mar 12, 2015
by
Eric Fiselier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add floating point comparison warnings
parent
f022d780
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
12 deletions
+18
-12
CMakeLists.txt
CMakeLists.txt
+1
-0
benchmark.cc
src/benchmark.cc
+2
-2
stat.h
src/stat.h
+10
-5
benchmark_test.cc
test/benchmark_test.cc
+1
-1
filter_test.cc
test/filter_test.cc
+4
-4
No files found.
CMakeLists.txt
View file @
66bf7c8f
...
@@ -39,6 +39,7 @@ add_cxx_compiler_flag(-Wshadow)
...
@@ -39,6 +39,7 @@ add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag
(
-Werror
)
add_cxx_compiler_flag
(
-Werror
)
add_cxx_compiler_flag
(
-pedantic-errors
)
add_cxx_compiler_flag
(
-pedantic-errors
)
add_cxx_compiler_flag
(
-Wshorten-64-to-32
)
add_cxx_compiler_flag
(
-Wshorten-64-to-32
)
add_cxx_compiler_flag
(
-Wfloat-equal
)
# TODO(ericwf): enable this for g++
# TODO(ericwf): enable this for g++
#add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
#add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
# Release flags
# Release flags
...
...
src/benchmark.cc
View file @
66bf7c8f
...
@@ -665,11 +665,11 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
...
@@ -665,11 +665,11 @@ void RunBenchmark(const benchmark::internal::Benchmark::Instance& b,
(
seconds
>=
FLAGS_benchmark_min_time
)
||
(
seconds
>=
FLAGS_benchmark_min_time
)
||
(
real_accumulated_time
>=
5
*
FLAGS_benchmark_min_time
))
{
(
real_accumulated_time
>=
5
*
FLAGS_benchmark_min_time
))
{
double
bytes_per_second
=
0
;
double
bytes_per_second
=
0
;
if
(
total
.
bytes_processed
>
0
&&
seconds
!=
0.0
)
{
if
(
total
.
bytes_processed
>
0
&&
seconds
>
0.0
)
{
bytes_per_second
=
(
total
.
bytes_processed
/
seconds
);
bytes_per_second
=
(
total
.
bytes_processed
/
seconds
);
}
}
double
items_per_second
=
0
;
double
items_per_second
=
0
;
if
(
total
.
items_processed
>
0
&&
seconds
!=
0.0
)
{
if
(
total
.
items_processed
>
0
&&
seconds
>
0.0
)
{
items_per_second
=
(
total
.
items_processed
/
seconds
);
items_per_second
=
(
total
.
items_processed
/
seconds
);
}
}
...
...
src/stat.h
View file @
66bf7c8f
...
@@ -2,8 +2,10 @@
...
@@ -2,8 +2,10 @@
#define BENCHMARK_STAT_H_
#define BENCHMARK_STAT_H_
#include <cmath>
#include <cmath>
#include <ostream>
#include <limits>
#include <limits>
#include <ostream>
#include <type_traits>
namespace
benchmark
{
namespace
benchmark
{
...
@@ -13,10 +15,10 @@ class Stat1;
...
@@ -13,10 +15,10 @@ class Stat1;
template
<
typename
VType
,
typename
NumType
>
template
<
typename
VType
,
typename
NumType
>
class
Stat1MinMax
;
class
Stat1MinMax
;
typedef
Stat1
<
float
,
floa
t
>
Stat1_f
;
typedef
Stat1
<
float
,
int64_
t
>
Stat1_f
;
typedef
Stat1
<
double
,
double
>
Stat1_d
;
typedef
Stat1
<
double
,
int64_t
>
Stat1_d
;
typedef
Stat1MinMax
<
float
,
floa
t
>
Stat1MinMax_f
;
typedef
Stat1MinMax
<
float
,
int64_
t
>
Stat1MinMax_f
;
typedef
Stat1MinMax
<
double
,
double
>
Stat1MinMax_d
;
typedef
Stat1MinMax
<
double
,
int64_t
>
Stat1MinMax_d
;
template
<
typename
VType
>
template
<
typename
VType
>
class
Vector2
;
class
Vector2
;
...
@@ -133,6 +135,9 @@ class Stat1 {
...
@@ -133,6 +135,9 @@ class Stat1 {
}
}
private
:
private
:
static_assert
(
std
::
is_integral
<
NumType
>::
value
&&
!
std
::
is_same
<
NumType
,
bool
>::
value
,
"NumType must be an integral type that is not bool."
);
// Let i be the index of the samples provided (using +=)
// Let i be the index of the samples provided (using +=)
// and weight[i],value[i] be the data of sample #i
// and weight[i],value[i] be the data of sample #i
// then the variables have the following meaning:
// then the variables have the following meaning:
...
...
test/benchmark_test.cc
View file @
66bf7c8f
...
@@ -158,7 +158,7 @@ static void BM_LongTest(benchmark::State& state) {
...
@@ -158,7 +158,7 @@ static void BM_LongTest(benchmark::State& state) {
while
(
state
.
KeepRunning
())
while
(
state
.
KeepRunning
())
for
(
int
i
=
0
;
i
<
state
.
range_x
();
++
i
)
for
(
int
i
=
0
;
i
<
state
.
range_x
();
++
i
)
tracker
+=
i
;
tracker
+=
i
;
assert
(
tracker
!=
0
.0
);
assert
(
tracker
>
1
.0
);
}
}
BENCHMARK
(
BM_LongTest
)
->
Range
(
1
<<
16
,
1
<<
28
);
BENCHMARK
(
BM_LongTest
)
->
Range
(
1
<<
16
,
1
<<
28
);
...
...
test/filter_test.cc
View file @
66bf7c8f
#include "benchmark/benchmark.h"
#include "benchmark/benchmark.h"
#include <
assert.h
>
#include <
cassert
>
#include <
math.
h>
#include <
cmat
h>
#include <
stdint.h
>
#include <
cstdint
>
#include <iostream>
#include <iostream>
#include <sstream>
#include <sstream>
...
@@ -69,7 +69,7 @@ BENCHMARK(BM_CalculatePi)->ThreadPerCpu();
...
@@ -69,7 +69,7 @@ BENCHMARK(BM_CalculatePi)->ThreadPerCpu();
int
main
(
int
argc
,
const
char
*
argv
[])
{
int
main
(
int
argc
,
const
char
*
argv
[])
{
benchmark
::
Initialize
(
&
argc
,
argv
);
benchmark
::
Initialize
(
&
argc
,
argv
);
assert
(
CalculatePi
(
1
)
==
0.0
);
assert
(
std
::
fabs
(
CalculatePi
(
1
))
<
0.001
);
TestReporter
test_reporter
;
TestReporter
test_reporter
;
benchmark
::
RunSpecifiedBenchmarks
(
&
test_reporter
);
benchmark
::
RunSpecifiedBenchmarks
(
&
test_reporter
);
...
...
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