Reputation: 319
I am having some big queries and loops which gives me an excel output.
I am facing trouble with the performance of excel generation. It takes lot of time. So I thought of optimizing the code, for which I would like to know which block of my code is taking how much time? Can any body help here please?
I just want to know how to dump the execution time of cfquery / cfloop/ cfoutput...?
Upvotes: 1
Views: 3098
Reputation: 29870
There is no automated way of seeing the execution time of a block of code in ColdFusion. The granularity is done at file level (or method-call level).
However it's easy enough to do with built-in functions. I do this:
startTime = getTickCount()
// block of code to time here
executionTime = getTickCount() - startTime
For repeated use, I have rolled this sort of thing into a UDF: http://www.cflib.org/udf/makeStopwatch (requires CF10+ / Railo4+)
Upvotes: 6
Reputation: 112230
You can wrap cftimer around blocks, which shows times in the debug info (if enabled). Or you can compare two calls to getTickCount to get times in a variable which you can output however you need.
Remember that the first request after a change includes a compilation overhead that doesn't always apply (it can be worthwhile refreshing the page a few times to get an average time).
For queries in particular, you can use tools such as FusionReactor to check how long it took, without having to modify your code.
Upvotes: 2