In case I'm not missing something, is there a way ...
# cfml-general
a
In case I'm not missing something, is there a way to see how frequently a method is called in a request? I'm trying to do some tuning and I'm sure there are methods being hit within loops but the arguments are the same and produce the same result. Not sure how to find them though. FusionReactor profiler helps but wondered if there is another way,
d
Does cfdebug info include that info? I never have it one and don't remember.
👍 1
a
Doesn't seem to. Good thought though
w
the standard built in debugging/template reports this i'm pretty sure, but of course requires debugging to be on
👍 1
also, i would imagine you might be able to pull it off using interceptors if your framework supports it
n
callStackGet() ?
b
In case you're still searching, here is something off the top of my head: just use coding-101 and string it out. In onRequestStart in Application.cfc:
<cfset var request.numberOfCalls={}>
In every method whose frequency you wish to measure:
<cfparam name="request.numberOfCalls.methodName" default="0">
<cfset request.numberOfCalls.methodName++>
Then, when the request ends, have a look at the result:
<cfdump var="#request.numberOfCalls#">
a
It's more to find which methods are being called excessively so they can be refactored.
I'm having trouble getting the cfdebugger working in my commandbox / ACF stack. Installed the module, enabled it but get no output, but haven't had a chance to dig further.
Just revisited it and just needed to add the IP (as not using 127.0.0.1) 🤦
b
Copy code
@aliaspooryorik: It's more to find which methods are being called excessively so they can be refactored.
The coding-101 I gave does in fact find which methods are called. In addition, according to your requirement: per request.
<cfloop from="1" to="101" index="i">
<cfset method1()>
</cfloop>
<cfloop from="101" to="1101" index="j">
<cfset method2()>
</cfloop>
<cffunction name="method1" >
<cfparam name="request.numberOfCalls.method1" default="0">
<cfset request.numberOfCalls.method1++>
</cffunction>
<cffunction name="method2" >
<cfparam name="request.numberOfCalls.method2" default="0">
<cfset request.numberOfCalls.method2++>
</cffunction>
<cfscript>
writedump(request.numberOfCalls);
</cfscript>
a
yeah, but, I'd need to add that code to every method in my entire application to know which ones are called excessively. We have over 20,000 methods. The cbdebugging template shows me what I wanted to know, including arguments which is a bonus.
b
Aha. Fair enough. Reading your post I thought you wished to debug just several methods.
b
In Lucee at least, you can write your own debugging templates to report on whatever you want really. We've done that in the past to make sure our automated testing framework is hitting target files (directly, as includes or as cf tags, etc...). If ACF has custom debug templates, I'd give that a shot.