Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
88eb4554
Commit
88eb4554
authored
Jun 24, 2015
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Revert to using gettimeofday to have measurements in us instead of ticks."
This reverts commit
89df764f
.
parent
5e481c97
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
17 deletions
+44
-17
src/core/stats.cpp
src/core/stats.cpp
+27
-3
src/core/util.cpp
src/core/util.cpp
+9
-8
src/core/util.h
src/core/util.h
+4
-2
src/jit.cpp
src/jit.cpp
+4
-4
No files found.
src/core/stats.cpp
View file @
88eb4554
...
@@ -138,17 +138,41 @@ void Stats::dump(bool includeZeros) {
...
@@ -138,17 +138,41 @@ void Stats::dump(bool includeZeros) {
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
());
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
());
uint64_t
ticks_in_main
=
0
;
uint64_t
accumulated_stat_timer_ticks
=
0
;
for
(
int
i
=
0
;
i
<
pairs
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
pairs
.
size
();
i
++
)
{
uint64_t
count
=
*
pairs
[
i
].
second
;
uint64_t
count
=
*
pairs
[
i
].
second
;
if
(
includeZeros
||
count
>
0
)
{
if
(
includeZeros
||
count
>
0
)
{
if
(
startswith
(
pairs
[
i
].
first
,
"us_
timer
_"
))
{
if
(
startswith
(
pairs
[
i
].
first
,
"us_
"
)
||
startswith
(
pairs
[
i
].
first
,
"_init_us
_"
))
{
fprintf
(
stderr
,
"%s: %lu
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
uint64_t
)(
count
/
cycles_per_us
));
fprintf
(
stderr
,
"%s: %lu
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
uint64_t
)(
count
/
cycles_per_us
));
}
else
{
}
else
fprintf
(
stderr
,
"%s: %lu
\n
"
,
pairs
[
i
].
first
.
c_str
(),
count
);
fprintf
(
stderr
,
"%s: %lu
\n
"
,
pairs
[
i
].
first
.
c_str
(),
count
);
}
if
(
startswith
(
pairs
[
i
].
first
,
"us_timer_"
))
accumulated_stat_timer_ticks
+=
count
;
if
(
pairs
[
i
].
first
==
"ticks_in_main"
)
ticks_in_main
=
count
;
}
}
}
}
if
(
includeZeros
||
accumulated_stat_timer_ticks
>
0
)
fprintf
(
stderr
,
"ticks_all_timers: %lu
\n
"
,
accumulated_stat_timer_ticks
);
#if 0
// I want to enable this, but am leaving it disabled for the time
// being because it causes test failures due to:
//
// 1) some tests exit from main from inside catch blocks, without
// going through the logic to stop the timers.
// 2) some tests create multiple threads which causes problems
// with our non-per thread stat timers.
if (ticks_in_main && ticks_in_main != accumulated_stat_timer_ticks) {
fprintf(stderr, "WARNING: accumulated stat timer ticks != ticks in main - don't trust timer output.");
}
#endif
fprintf
(
stderr
,
"(End of stats)
\n
"
);
fprintf
(
stderr
,
"(End of stats)
\n
"
);
}
}
...
...
src/core/util.cpp
View file @
88eb4554
...
@@ -44,7 +44,7 @@ void Timer::restart(const char* newdesc) {
...
@@ -44,7 +44,7 @@ void Timer::restart(const char* newdesc) {
assert
(
ended
);
assert
(
ended
);
desc
=
newdesc
;
desc
=
newdesc
;
gettimeofday
(
&
start_time
,
NULL
);
start_time
=
getCPUTicks
(
);
Timer
::
level
++
;
Timer
::
level
++
;
ended
=
false
;
ended
=
false
;
}
}
...
@@ -54,14 +54,14 @@ void Timer::restart(const char* newdesc, long new_min_usec) {
...
@@ -54,14 +54,14 @@ void Timer::restart(const char* newdesc, long new_min_usec) {
restart
(
newdesc
);
restart
(
newdesc
);
}
}
uint64_t
Timer
::
end
()
{
uint64_t
Timer
::
end
(
uint64_t
*
ended_at
)
{
if
(
!
ended
)
{
if
(
!
ended
)
{
timeval
end
;
uint64_t
end
=
getCPUTicks
();
gettimeofday
(
&
end
,
NULL
);
uint64_t
duration
=
end
-
start_time
;
long
us
=
1000000L
*
(
end
.
tv_sec
-
start_time
.
tv_sec
)
+
(
end
.
tv_usec
-
start_time
.
tv_usec
);
Timer
::
level
--
;
Timer
::
level
--
;
if
(
VERBOSITY
(
"time"
)
>=
2
&&
desc
)
{
if
(
VERBOSITY
(
"time"
)
>=
2
&&
desc
)
{
uint64_t
us
=
(
uint64_t
)(
duration
/
Stats
::
estimateCPUFreq
());
if
(
us
>
min_usec
)
{
if
(
us
>
min_usec
)
{
for
(
int
i
=
0
;
i
<
Timer
::
level
;
i
++
)
{
for
(
int
i
=
0
;
i
<
Timer
::
level
;
i
++
)
{
putchar
(
' '
);
putchar
(
' '
);
...
@@ -78,9 +78,10 @@ uint64_t Timer::end() {
...
@@ -78,9 +78,10 @@ uint64_t Timer::end() {
fflush
(
stdout
);
fflush
(
stdout
);
}
}
}
}
if
(
ended_at
)
*
ended_at
=
end
;
ended
=
true
;
ended
=
true
;
return
duration
;
return
us
;
}
}
return
-
1
;
return
-
1
;
}
}
...
...
src/core/util.h
View file @
88eb4554
...
@@ -36,7 +36,7 @@ inline uint64_t getCPUTicks() {
...
@@ -36,7 +36,7 @@ inline uint64_t getCPUTicks() {
class
Timer
{
class
Timer
{
private:
private:
static
int
level
;
static
int
level
;
timeval
start_time
;
uint64_t
start_time
;
const
char
*
desc
;
const
char
*
desc
;
long
min_usec
;
long
min_usec
;
bool
ended
;
bool
ended
;
...
@@ -55,12 +55,14 @@ public:
...
@@ -55,12 +55,14 @@ public:
// returns the duration. if @ended_at is non-null, it's filled in
// returns the duration. if @ended_at is non-null, it's filled in
// with the tick the timer stopped at.
// with the tick the timer stopped at.
uint64_t
end
();
uint64_t
end
(
uint64_t
*
ended_at
=
NULL
);
uint64_t
split
(
const
char
*
newdesc
=
NULL
)
{
uint64_t
split
(
const
char
*
newdesc
=
NULL
)
{
uint64_t
rtn
=
end
();
uint64_t
rtn
=
end
();
restart
(
newdesc
);
restart
(
newdesc
);
return
rtn
;
return
rtn
;
}
}
uint64_t
getStartTime
()
const
{
return
start_time
;
}
};
};
#else // DISABLE_TIMERS
#else // DISABLE_TIMERS
...
...
src/jit.cpp
View file @
88eb4554
...
@@ -265,12 +265,12 @@ static int main(int argc, char** argv) {
...
@@ -265,12 +265,12 @@ static int main(int argc, char** argv) {
timespec
before_ts
,
after_ts
;
timespec
before_ts
,
after_ts
;
uint64_t
main_time_started_at
=
getCPUTicks
()
;
Timer
main_time
;
int
rtncode
=
0
;
int
rtncode
=
0
;
{
{
#if STAT_TIMERS
#if STAT_TIMERS
StatTimer
timer
(
Stats
::
getStatCounter
(
"us_timer_main_toplevel"
),
0
,
true
);
StatTimer
timer
(
Stats
::
getStatCounter
(
"us_timer_main_toplevel"
),
0
,
true
);
timer
.
pushTopLevel
(
main_time
_started_at
);
timer
.
pushTopLevel
(
main_time
.
getStartTime
()
);
#endif
#endif
int
code
;
int
code
;
...
@@ -506,8 +506,8 @@ static int main(int argc, char** argv) {
...
@@ -506,8 +506,8 @@ static int main(int argc, char** argv) {
_t
.
split
(
"finishing up"
);
_t
.
split
(
"finishing up"
);
#if STAT_TIMERS
#if STAT_TIMERS
uint64_t
main_time_ended_at
=
getCPUTicks
()
;
uint64_t
main_time_ended_at
;
uint64_t
main_time_duration
=
main_time
_ended_at
-
main_time_started_at
;
uint64_t
main_time_duration
=
main_time
.
end
(
&
main_time_ended_at
)
;
static
StatCounter
mt
(
"ticks_in_main"
);
static
StatCounter
mt
(
"ticks_in_main"
);
mt
.
log
(
main_time_duration
);
mt
.
log
(
main_time_duration
);
...
...
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