lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tuesday 15 February 2005 14:15, David Burgess wrote:
> On Tue, 15 Feb 2005 14:
> > One million setjmp/longjmp plus the surrounding overhead easily complete
> > in one and a half seconds on my machine.
> >
> > But one million C++ try/catch/throw need more than a minute (!) to
> > complete. Yuck!
>
> Your platform and compiler?

I think he said Visual C++, which is notorious for its lousy exception 
support. I wonder what the same benchmark would be like on gcc?

setjmp() and longjmp() are a lot more sophisticated than they look; the 
compiler requires special knowledge of them in order to do things like make 
sure that variables aren't cached in registers across a setjmp() call, for 
example. C++ exceptions would need to do the same, but they have more 
restricted semantics that simplify matters considerably... assuming that the 
objects being thrown are scalars, and not multi-byte objects, I don't see why 
C++ exceptions can't be nearly as fast as longjmp().

(PS. *Please* don't top post! It makes it really annoying to follow 
conversations!)

-- 
+- David Given --McQ-+ "The lessons of history teach us --- if the
|  dg@cowlark.com    | lessons of history teach us anything --- that
| (dg@tao-group.com) | nobody learns the lessons that history teaches us."
+- www.cowlark.com --+ --- Robert Heinlein