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
d30281e3
Commit
d30281e3
authored
Apr 23, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add an option for not including stats with 0 counters (useful for when we're clearing stats)
parent
bdaaf6b6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
src/core/stats.cpp
src/core/stats.cpp
+3
-2
src/core/stats.h
src/core/stats.h
+1
-1
src/runtime/builtin_modules/pyston.cpp
src/runtime/builtin_modules/pyston.cpp
+7
-3
No files found.
src/core/stats.cpp
View file @
d30281e3
...
@@ -51,7 +51,7 @@ int Stats::getStatId(const std::string& name) {
...
@@ -51,7 +51,7 @@ int Stats::getStatId(const std::string& name) {
return
rtn
;
return
rtn
;
}
}
void
Stats
::
dump
()
{
void
Stats
::
dump
(
bool
includeZeros
)
{
if
(
!
Stats
::
enabled
)
if
(
!
Stats
::
enabled
)
return
;
return
;
...
@@ -65,7 +65,8 @@ void Stats::dump() {
...
@@ -65,7 +65,8 @@ void Stats::dump() {
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
());
std
::
sort
(
pairs
.
begin
(),
pairs
.
end
());
for
(
int
i
=
0
;
i
<
pairs
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
pairs
.
size
();
i
++
)
{
printf
(
"%s: %ld
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
*
counts
)[
pairs
[
i
].
second
]);
if
(
includeZeros
||
(
*
counts
)[
pairs
[
i
].
second
]
>
0
)
printf
(
"%s: %ld
\n
"
,
pairs
[
i
].
first
.
c_str
(),
(
*
counts
)[
pairs
[
i
].
second
]);
}
}
}
}
...
...
src/core/stats.h
View file @
d30281e3
...
@@ -41,7 +41,7 @@ public:
...
@@ -41,7 +41,7 @@ public:
static
void
log
(
int
id
,
int
count
=
1
)
{
(
*
counts
)[
id
]
+=
count
;
}
static
void
log
(
int
id
,
int
count
=
1
)
{
(
*
counts
)[
id
]
+=
count
;
}
static
void
clear
()
{
std
::
fill
(
counts
->
begin
(),
counts
->
end
(),
0
);
}
static
void
clear
()
{
std
::
fill
(
counts
->
begin
(),
counts
->
end
(),
0
);
}
static
void
dump
();
static
void
dump
(
bool
includeZeros
=
true
);
static
void
endOfInit
();
static
void
endOfInit
();
};
};
...
...
src/runtime/builtin_modules/pyston.cpp
View file @
d30281e3
...
@@ -53,8 +53,11 @@ static Box* clearStats() {
...
@@ -53,8 +53,11 @@ static Box* clearStats() {
return
None
;
return
None
;
}
}
static
Box
*
dumpStats
()
{
static
Box
*
dumpStats
(
Box
*
includeZeros
)
{
Stats
::
dump
();
if
(
includeZeros
->
cls
!=
bool_cls
)
raiseExcHelper
(
TypeError
,
"includeZeros must be a 'bool' object but received a '%s'"
,
getTypeName
(
includeZeros
));
Stats
::
dump
(((
BoxedBool
*
)
includeZeros
)
->
n
!=
0
);
return
None
;
return
None
;
}
}
...
@@ -67,6 +70,7 @@ void setupPyston() {
...
@@ -67,6 +70,7 @@ void setupPyston() {
pyston_module
->
giveAttr
(
"clearStats"
,
pyston_module
->
giveAttr
(
"clearStats"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
clearStats
,
NONE
,
0
),
"clearStats"
));
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
clearStats
,
NONE
,
0
),
"clearStats"
));
pyston_module
->
giveAttr
(
"dumpStats"
,
pyston_module
->
giveAttr
(
"dumpStats"
,
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
dumpStats
,
NONE
,
0
),
"dumpStats"
));
new
BoxedBuiltinFunctionOrMethod
(
boxRTFunction
((
void
*
)
dumpStats
,
NONE
,
1
,
1
,
false
,
false
),
"dumpStats"
,
{
False
}));
}
}
}
}
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