Groups
Groups
Sign in
Groups
Groups
cnodejs
Conversations
About
Send feedback
Help
关于记日志时取函数栈的性能问题
21 views
Skip to first unread message
souledge
unread,
Jun 7, 2012, 2:30:31 AM
6/7/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cno...@googlegroups.com
想用nodejs写个comet server,测试了一下log的性能,发现不尽如人意,debug后定位到性能消耗主要在
new Error().stack; 这一行,这里是我用来记录日志发生的文件名和行号用的。
我在虚拟机上benchmark大概每秒只有3k左右,把stack的tracelimit调小到3,也大概只有6k左右。
这个性能完全没法接受啊。请教一下各位有没有什么别的方法能够以较小的开销获取到行号和文件名等信息?
mk2
unread,
Jun 7, 2012, 9:03:40 AM
6/7/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cno...@googlegroups.com
代码分享看看?
---------------------------------------------
MK2, FaWave, Net4Team ☺
TEL:
18668079069
微博: @Python发烧友
Twitter: @fengmk2
Blog:
http://fengmk2.cnblogs.com/
souledge
unread,
Jun 11, 2012, 1:47:35 AM
6/11/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to cno...@googlegroups.com
代码很简单:
Error.stackTraceLimit = 3;
var e = new Error();
var line = e.stack.split("\n")[3];
就是以上2行的benchmark在虚拟机上只能到6k
在 2012年6月7日星期四UTC+8下午9时03分40秒,MK2写道:
Reply all
Reply to author
Forward
0 new messages