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
3c972d7b
Commit
3c972d7b
authored
Apr 22, 2015
by
Chris Toshok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dump stats on Ctrl-C as well as normal exit
parent
b1bd16be
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
10 deletions
+13
-10
src/codegen/entry.cpp
src/codegen/entry.cpp
+1
-0
src/core/stats.cpp
src/core/stats.cpp
+4
-0
src/core/stats.h
src/core/stats.h
+3
-0
src/jit.cpp
src/jit.cpp
+5
-10
No files found.
src/codegen/entry.cpp
View file @
3c972d7b
...
@@ -362,6 +362,7 @@ static void handle_sigint(int signum) {
...
@@ -362,6 +362,7 @@ static void handle_sigint(int signum) {
// For now, just call abort(), so that we get a traceback at least.
// For now, just call abort(), so that we get a traceback at least.
fprintf
(
stderr
,
"SIGINT!
\n
"
);
fprintf
(
stderr
,
"SIGINT!
\n
"
);
joinRuntime
();
joinRuntime
();
Stats
::
dump
();
abort
();
abort
();
}
}
...
...
src/core/stats.cpp
View file @
3c972d7b
...
@@ -23,6 +23,7 @@ namespace pyston {
...
@@ -23,6 +23,7 @@ namespace pyston {
#if !DISABLE_STATS
#if !DISABLE_STATS
std
::
vector
<
long
>*
Stats
::
counts
;
std
::
vector
<
long
>*
Stats
::
counts
;
std
::
unordered_map
<
int
,
std
::
string
>*
Stats
::
names
;
std
::
unordered_map
<
int
,
std
::
string
>*
Stats
::
names
;
bool
Stats
::
enabled
;
StatCounter
::
StatCounter
(
const
std
::
string
&
name
)
:
id
(
Stats
::
getStatId
(
name
))
{
StatCounter
::
StatCounter
(
const
std
::
string
&
name
)
:
id
(
Stats
::
getStatId
(
name
))
{
}
}
...
@@ -51,6 +52,9 @@ int Stats::getStatId(const std::string& name) {
...
@@ -51,6 +52,9 @@ int Stats::getStatId(const std::string& name) {
}
}
void
Stats
::
dump
()
{
void
Stats
::
dump
()
{
if
(
!
Stats
::
enabled
)
return
;
printf
(
"Stats:
\n
"
);
printf
(
"Stats:
\n
"
);
std
::
vector
<
std
::
pair
<
std
::
string
,
int
>>
pairs
;
std
::
vector
<
std
::
pair
<
std
::
string
,
int
>>
pairs
;
...
...
src/core/stats.h
View file @
3c972d7b
...
@@ -32,10 +32,12 @@ struct Stats {
...
@@ -32,10 +32,12 @@ struct Stats {
private:
private:
static
std
::
vector
<
long
>*
counts
;
static
std
::
vector
<
long
>*
counts
;
static
std
::
unordered_map
<
int
,
std
::
string
>*
names
;
static
std
::
unordered_map
<
int
,
std
::
string
>*
names
;
static
bool
enabled
;
public:
public:
static
int
getStatId
(
const
std
::
string
&
name
);
static
int
getStatId
(
const
std
::
string
&
name
);
static
void
setEnabled
(
bool
enabled
)
{
Stats
::
enabled
=
enabled
;
}
static
void
log
(
int
id
,
int
count
=
1
)
{
(
*
counts
)[
id
]
+=
count
;
}
static
void
log
(
int
id
,
int
count
=
1
)
{
(
*
counts
)[
id
]
+=
count
;
}
static
void
dump
();
static
void
dump
();
...
@@ -64,6 +66,7 @@ public:
...
@@ -64,6 +66,7 @@ public:
#else
#else
struct
Stats
{
struct
Stats
{
static
void
setEnabled
(
bool
enabled
)
{}
static
void
dump
()
{
printf
(
"(Stats disabled)
\n
"
);
}
static
void
dump
()
{
printf
(
"(Stats disabled)
\n
"
);
}
static
void
log
(
int
id
,
int
count
=
1
)
{}
static
void
log
(
int
id
,
int
count
=
1
)
{}
static
int
getStatId
(
const
std
::
string
&
name
)
{
return
0
;
}
static
int
getStatId
(
const
std
::
string
&
name
)
{
return
0
;
}
...
...
src/jit.cpp
View file @
3c972d7b
...
@@ -95,7 +95,6 @@ static int main(int argc, char** argv) {
...
@@ -95,7 +95,6 @@ static int main(int argc, char** argv) {
int
code
;
int
code
;
bool
force_repl
=
false
;
bool
force_repl
=
false
;
bool
stats
=
false
;
bool
unbuffered
=
false
;
bool
unbuffered
=
false
;
const
char
*
command
=
NULL
;
const
char
*
command
=
NULL
;
...
@@ -123,7 +122,7 @@ static int main(int argc, char** argv) {
...
@@ -123,7 +122,7 @@ static int main(int argc, char** argv) {
}
else
if
(
code
==
'j'
)
{
}
else
if
(
code
==
'j'
)
{
DUMPJIT
=
true
;
DUMPJIT
=
true
;
}
else
if
(
code
==
's'
)
{
}
else
if
(
code
==
's'
)
{
stats
=
true
;
Stats
::
setEnabled
(
true
)
;
}
else
if
(
code
==
'S'
)
{
}
else
if
(
code
==
'S'
)
{
Py_NoSiteFlag
=
1
;
Py_NoSiteFlag
=
1
;
}
else
if
(
code
==
'u'
)
{
}
else
if
(
code
==
'u'
)
{
...
@@ -241,8 +240,7 @@ static int main(int argc, char** argv) {
...
@@ -241,8 +240,7 @@ static int main(int argc, char** argv) {
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
int
retcode
=
1
;
int
retcode
=
1
;
(
void
)
handle_toplevel_exn
(
e
,
&
retcode
);
(
void
)
handle_toplevel_exn
(
e
,
&
retcode
);
if
(
stats
)
Stats
::
dump
();
Stats
::
dump
();
return
retcode
;
return
retcode
;
}
}
}
}
...
@@ -269,8 +267,7 @@ static int main(int argc, char** argv) {
...
@@ -269,8 +267,7 @@ static int main(int argc, char** argv) {
int
retcode
=
1
;
int
retcode
=
1
;
(
void
)
handle_toplevel_exn
(
e
,
&
retcode
);
(
void
)
handle_toplevel_exn
(
e
,
&
retcode
);
if
(
!
force_repl
)
{
if
(
!
force_repl
)
{
if
(
stats
)
Stats
::
dump
();
Stats
::
dump
();
return
retcode
;
return
retcode
;
}
}
}
}
...
@@ -320,8 +317,7 @@ static int main(int argc, char** argv) {
...
@@ -320,8 +317,7 @@ static int main(int argc, char** argv) {
}
catch
(
ExcInfo
e
)
{
}
catch
(
ExcInfo
e
)
{
int
retcode
=
0xdeadbeef
;
// should never be seen
int
retcode
=
0xdeadbeef
;
// should never be seen
if
(
handle_toplevel_exn
(
e
,
&
retcode
))
{
if
(
handle_toplevel_exn
(
e
,
&
retcode
))
{
if
(
stats
)
Stats
::
dump
();
Stats
::
dump
();
return
retcode
;
return
retcode
;
}
}
}
}
...
@@ -340,8 +336,7 @@ static int main(int argc, char** argv) {
...
@@ -340,8 +336,7 @@ static int main(int argc, char** argv) {
int
rtncode
=
joinRuntime
();
int
rtncode
=
joinRuntime
();
_t
.
split
(
"finishing up"
);
_t
.
split
(
"finishing up"
);
if
(
stats
)
Stats
::
dump
();
Stats
::
dump
();
return
rtncode
;
return
rtncode
;
}
}
...
...
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