Re: [cpp] 请问:3000个try{}catch{}宏是否会影响程序的性能呢?
巤邓
tdzl2003 at gmail.com
Thu Dec 20 19:51:18 CST 2007
不需要try 和catch。try和catch会影响性能。
可以用throw结合Calling stack的trace back。
仅仅一个行号的话,在最外面有一个try-catch就可以记录崩溃了,不需要3000对的try-catch
throw当你没throw的时候基本不影响性能。(好像是废话,哈哈)
On 12/20/07, qiaojie <qiaojie at gmail.com> wrote:
>
> 用这种方法记录出错点非常的傻
>
>
> 在07-12-20,Carl Liu(Henyep SZ) <xxliu at cn.henyep.com> 写道:
> >
> > 最近准备开发一个服务器程序,为了在程序崩溃时得到出错的代码位置(文件名,行数), 我想通过TRY/CATCH的机制自定义一个宏来实现。如下:
> > #define rp(x) \
> > try{x;}\
> > catch (...)\
> > {CString str; str.Format("Crashed on Line:%d,in File:%s",__LINE__,
> > __FILE__) ;AddtoLog(str, LOG_RELEASE) ; exit(1) ;}
> > 3000组左右的TRY/CATCH
> > 这样,在程序中涉及到内存操作的代码都会加上这个宏 (如, rp( memcpy(dest,src,size_t))
> > ;),大概会增加3000组左右的TRY/CATCH, 问题在于这3000~5000组左右额外的TRY/CATCH对性能的影响有多大?
> >
> >
> >
> >
> > -----------------------------------
> > Regards
> >
> >
> > Carl
> > -----------------------------------
> >
> >
> > ------------------------------
> >
> >
> >
> > _______________________________________________
> > Cpp mailing list
> > Cpp at codingnow.com
> > http://codingnow.com/mailman/listinfo/cpp
> >
> >
>
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codingnow.com/pipermail/cpp/attachments/20071220/ba9136b8/attachment-0001.html
More information about the Cpp
mailing list