Benchmarks revisited
ColdFusion
After my last blog post regarding performance differences between various functions and between accessing them with cfscript vs. tag based calls, I got an email from reader Robert Froehling, who said the following:
Your article, Benchmarks - try VS isdefined() & script VS tag, got me thinking about how the various functions, that can be used to determine a variables existence or value, perform. So I decided to do a little testing myself. I setup the tests almost exactly the way you did, just using different functions. I used Len(), IsDefined(), Compare(), and StructKeyExists(). Personally, I've been using Len() for a while now. Obviously, it requires you to use <cfparam> for all of the potential variables. But this doesn't bother me much. I ran each test 10 times to come up with an average. It turned out that Len() and Compare() using <cfscript> are the leaders at an average of 60 milliseconds. Attached are my results.
Just thought I'd share.
Fro
It appears that his tests too seem to add weight to cfscript being notably faster on the functions he tested.
With his permission to share, here are his results:
Your article, Benchmarks - try VS isdefined() & script VS tag, got me thinking about how the various functions, that can be used to determine a variables existence or value, perform. So I decided to do a little testing myself. I setup the tests almost exactly the way you did, just using different functions. I used Len(), IsDefined(), Compare(), and StructKeyExists(). Personally, I've been using Len() for a while now. Obviously, it requires you to use <cfparam> for all of the potential variables. But this doesn't bother me much. I ran each test 10 times to come up with an average. It turned out that Len() and Compare() using <cfscript> are the leaders at an average of 60 milliseconds. Attached are my results.
Just thought I'd share.
Fro
It appears that his tests too seem to add weight to cfscript being notably faster on the functions he tested.
With his permission to share, here are his results:
| Len() | IsDefined() | Compare() | StructKeyExists() | |||||
| Block | Script | Block | Script | Block | Script | Block | Script | |
| 1 | 547 | 156 | 469 | 140 | 344 | 140 | 265 | 187 |
| 2 | 172 | 250 | 172 | 219 | 125 | 219 | 344 | 235 |
| 3 | 125 | 31 | 172 | 79 | 125 | 32 | 203 | 110 |
| 4 | 125 | 16 | 172 | 78 | 125 | 31 | 203 | 109 |
| 5 | 125 | 16 | 171 | 94 | 141 | 31 | 203 | 109 |
| 6 | 125 | 31 | 171 | 79 | 125 | 31 | 203 | 110 |
| 7 | 141 | 31 | 172 | 79 | 110 | 31 | 203 | 109 |
| 8 | 125 | 31 | 172 | 78 | 109 | 16 | 203 | 109 |
| 9 | 125 | 15 | 156 | 78 | 109 | 31 | 204 | 109 |
| 10 | 109 | 31 | 172 | 79 | 109 | 31 | 203 | 94 |
| Average | 171.9 | 60.8 | 199.9 | 100.3 | 142.2 | 59.3 | 223.4 | 128.1 |





Loading....