简体   繁体   English

萤火虫-如何检测已调用的函数或从何处调用了函数

[英]firebug - how can I detect what functions have been called or from where a function has been called

I am trying to optimize a script and I'm using firebug profiler to see what functions use most time to start from there. 我正在尝试优化脚本,并且正在使用Firebug探查器来查看哪些功能最常用来从那里开始。

My problem is that the script uses jQuery and raphaeljs and their functions, events etc are listed as "anonymous". 我的问题是该脚本使用jQuery和raphaeljs,它们的功能,事件等被列为“匿名”。 All of them. 他们全部。

As you can see in the image below everything I defined appears with name. 如您所见,在下面的图像中,我定义的所有内容均带有名称。

Here's a image of what I see (the image is readable just zoom a bit (ctrl + "+")). 这是我所看到的图像(可以放大一点(ctrl +“ +”)即可读取该图像)。

在此处输入图片说明

Since I don't plan to modify jQuery or raphael I don't really care what's the name of the function called (tho it would be nice to know) but I'm really interested on where did that function has been called from (to see if I can reduce the number of calls or something). 由于我不打算修改jQuery或raphael,所以我并不在乎这个函数的名称是什么(知道这很高兴),但是我真的很感兴趣该函数从哪里被调用(到看看我是否可以减少通话次数或其他次数)。 Any idea how to do that? 任何想法如何做到这一点?

Thank you for your help. 谢谢您的帮助。

In Firebug, use the stack panel to identify who is calling and who has been called. 在Firebug中,使用堆栈面板识别正在呼叫的人和被呼叫的人。 During the debug process, use the unminified version of the scripts in order to breakpoint in the proper positions. 在调试过程中,请使用脚本的最小版本以在适当位置断点。

To find which function called the current function use this : 要查找哪个函数称为当前函数,请使用以下命令:

alert(arguments.callee.caller.name);

This will alert the name of caller function. 这将提醒调用者函数的名称。 You can also use hierarchy like this : 您还可以使用如下层次结构:

arguments.callee.caller.caller.name 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM