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
05e14eb3
Commit
05e14eb3
authored
Jan 18, 2015
by
Kevin Modzelewski
Committed by
Kevin Modzelewski
Jan 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some exception benchmarks and tests
parent
aac0d9e6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
129 additions
and
0 deletions
+129
-0
microbenchmarks/exceptions_ubench.py
microbenchmarks/exceptions_ubench.py
+11
-0
test/bench_exceptions.cpp
test/bench_exceptions.cpp
+88
-0
test/tests/sys_excinfo.py
test/tests/sys_excinfo.py
+30
-0
No files found.
microbenchmarks/exceptions_ubench.py
0 → 100644
View file @
05e14eb3
def
f
():
# Try to eliminate as much non-exception stuff as possible:
from
__builtin__
import
Exception
e
=
Exception
()
for
i
in
xrange
(
100000
):
try
:
raise
e
except
Exception
:
pass
f
()
test/bench_exceptions.cpp
0 → 100644
View file @
05e14eb3
#include <vector>
#include <cstdio>
#include "stdint.h"
struct
ExcInfo
{
int64_t
a
,
b
,
c
;
};
void
bench0
()
{
int64_t
t
=
0
;
for
(
int
i
=
0
;
i
<
1000000
;
i
++
)
{
try
{
throw
0
;
}
catch
(
int
x
)
{
}
}
printf
(
"%ld
\n
"
,
t
);
}
void
bench1
()
{
int64_t
t
=
1
;
for
(
int
i
=
0
;
i
<
1000000
;
i
++
)
{
try
{
throw
ExcInfo
({.
a
=
t
,
.
b
=
t
,
.
c
=
t
});
}
catch
(
ExcInfo
e
)
{
t
+=
e
.
a
+
e
.
b
+
e
.
c
;
}
}
printf
(
"b1 %ld
\n
"
,
t
);
}
static
__thread
ExcInfo
curexc
;
struct
ExceptionOccurred
{
};
void
bench2
()
{
int64_t
t
=
1
;
for
(
int
i
=
0
;
i
<
1000000
;
i
++
)
{
try
{
curexc
.
a
=
t
;
curexc
.
b
=
t
;
curexc
.
c
=
t
;
throw
ExceptionOccurred
();
}
catch
(
ExceptionOccurred
)
{
t
+=
curexc
.
a
+
curexc
.
b
+
curexc
.
c
;
}
}
printf
(
"b2 %ld
\n
"
,
t
);
}
void
rbench1
()
{
int64_t
t
=
1
;
for
(
int
i
=
0
;
i
<
1000000
;
i
++
)
{
try
{
try
{
throw
ExcInfo
({.
a
=
t
,
.
b
=
t
,
.
c
=
t
});
}
catch
(
ExcInfo
e
)
{
throw
e
;
}
}
catch
(
ExcInfo
e
)
{
t
+=
e
.
a
+
e
.
b
+
e
.
c
;
}
}
printf
(
"rb1 %ld
\n
"
,
t
);
}
void
rbench2
()
{
int64_t
t
=
1
;
for
(
int
i
=
0
;
i
<
1000000
;
i
++
)
{
try
{
try
{
curexc
.
a
=
t
;
curexc
.
b
=
t
;
curexc
.
c
=
t
;
throw
ExceptionOccurred
();
}
catch
(
ExceptionOccurred
x
)
{
throw
x
;
}
}
catch
(
ExceptionOccurred
)
{
t
+=
curexc
.
a
+
curexc
.
b
+
curexc
.
c
;
}
}
printf
(
"rb2 %ld
\n
"
,
t
);
}
int
main
()
{
bench1
();
}
test/tests/sys_excinfo.py
View file @
05e14eb3
...
...
@@ -216,3 +216,33 @@ def f12():
print
"after next:"
,
sys
.
exc_info
()[
0
]
list
(
i
)
f12
()
# If an exception is thrown+caught in course of exception-matching, we need to still operate on the original exception:
def
f13
():
print
print
"f13"
def
inner
():
try
:
raise
KeyError
except
:
pass
print
sys
.
exc_info
()[
0
]
return
ZeroDivisionError
# This applies to what goes into exc_info:
try
:
1
/
0
except
inner
():
print
sys
.
exc_info
()[
0
]
# This also applies to the exception that will propagate:
try
:
try
:
raise
AttributeError
()
except
inner
():
print
"shouldn't get here!"
except
Exception
,
e
:
print
type
(
e
)
print
sys
.
exc_info
()[
0
]
f13
()
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