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
dc5b533a
Commit
dc5b533a
authored
Jan 08, 2014
by
Dominic Hamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove tunable estimate for cycles per second
parent
9d230ffb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
sysinfo.cc
src/sysinfo.cc
+10
-13
No files found.
src/sysinfo.cc
View file @
dc5b533a
...
...
@@ -20,21 +20,18 @@
namespace
benchmark
{
namespace
{
const
int64_t
estimate_time_ms
=
1000
;
pthread_once_t
cpuinfo_init
=
PTHREAD_ONCE_INIT
;
double
cpuinfo_cycles_per_second
=
1.0
;
int
cpuinfo_num_cpus
=
1
;
// Conservative guess
static
pthread_mutex_t
cputimens_mutex
;
pthread_mutex_t
cputimens_mutex
;
// Helper function estimates cycles/sec by observing cycles elapsed during
// sleep(). Using small sleep time decreases accuracy significantly.
int64_t
EstimateCyclesPerSecond
(
const
int
estimate_time_ms
)
{
CHECK
(
estimate_time_ms
>
0
);
double
multiplier
=
1000.0
/
(
double
)
estimate_time_ms
;
// scale by this much
int64_t
EstimateCyclesPerSecond
()
{
const
int64_t
start_ticks
=
cycleclock
::
Now
();
SleepForMilliseconds
(
estimate_time_ms
);
const
int64_t
guess
=
int64_t
(
multiplier
*
(
cycleclock
::
Now
()
-
start_ticks
));
return
guess
;
return
cycleclock
::
Now
()
-
start_ticks
;
}
// Helper function for reading an int from a file. Returns true if successful
...
...
@@ -99,9 +96,9 @@ void InitializeSystemInfo() {
if
(
fd
==
-
1
)
{
perror
(
pname
);
if
(
!
saw_mhz
)
{
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
1000
);
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
();
}
return
;
// TODO: use generic tester instead?
return
;
}
double
bogo_clock
=
1.0
;
...
...
@@ -166,7 +163,7 @@ void InitializeSystemInfo() {
cpuinfo_cycles_per_second
=
bogo_clock
;
}
else
{
// If we don't even have bogomips, we'll use the slow estimation.
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
1000
);
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
();
}
}
if
(
num_cpus
==
0
)
{
...
...
@@ -202,7 +199,7 @@ void InitializeSystemInfo() {
if
(
sysctlbyname
(
sysctl_path
,
&
hz
,
&
sz
,
NULL
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Unable to determine clock rate from sysctl: %s: %s
\n
"
,
sysctl_path
,
strerror
(
errno
));
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
1000
);
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
();
}
else
{
cpuinfo_cycles_per_second
=
hz
;
}
...
...
@@ -222,7 +219,7 @@ void InitializeSystemInfo() {
"~MHz"
,
NULL
,
&
data
,
&
data_size
)))
cpuinfo_cycles_per_second
=
(
int64
)
data
*
(
int64
)(
1000
*
1000
);
// was mhz
else
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
500
);
// TODO <500?
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
);
// TODO: also figure out cpuinfo_num_cpus
#elif defined OS_MACOSX
...
...
@@ -251,7 +248,7 @@ void InitializeSystemInfo() {
#else
// Generic cycles per second counter
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
(
1000
);
cpuinfo_cycles_per_second
=
EstimateCyclesPerSecond
();
#endif
}
}
// end namespace
...
...
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