IntelliJ调试器:计算函数被调用的次数

huangapple go评论59阅读模式
英文:

IntelliJ Debugger: Count how many times a function is called

问题

我想要计算程序中某个函数被调用的总次数。该方法在不同的对象中被调用,我不想通过传递一个变量并让它们都累加到该变量上。

在 IntelliJ Debugger 中是否有一个功能可以统计函数被调用的总次数?

具体而言,我的程序是一个用于图问题的搜索树算法,我想要计算生成的搜索树有多少不同的分支。每个分支对应一次提到的函数调用。

英文:

I want to count how many times a function is called overall in my program. The method is called in different objects and I dont want to pass one variable through and let them all add to it.
Is there a feature in the IntelliJ Debugger that's counts how often a function is called overall?

Specificially, my program is a search-tree algorithm for a graph-problem and I want to count, how many different branches the generated search-tree has. Each of these branches corresponds to a call of the mentioned function.

答案1

得分: 3

  1. 设置一个断点
  2. 取消勾选暂停
  3. 勾选“断点命中”消息
  4. 运行代码后,搜索打印的消息并找到计数。
英文:

IntelliJ调试器:计算函数被调用的次数

  1. Set up a breakpoint
  2. Uncheck the suspend
  3. Check the "Breakpoint hit" message
  4. After running the code, search the printed message and find the count.

huangapple
  • 本文由 发表于 2020年4月11日 05:30:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/61148980.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定