# [thelist] CF: Tip - Usage of Boolean Values

Buffington, Michael michael.buffington at office.xerox.com
Wed Jul 16 02:51:00 CDT 2003

```[snip]
A simple little trick: Cold Fusion usually processes a cfif tag like this

   <cfif variable.is_true>

more quickly than

   <cfif variable.is_true EQ "Yes">
[/snip]

Was reading Frank's tip and thought it would be worth conducting an experiment. The following code proves what Frank suggested, and introduces something Frank didn't mention, which is checking to see if a Boolean value is false (method 3 in my experiment). Also, I'm using cfscript, but it should all end up being the same in the end. On average, method 1 and 3 run the fastest, about 31ms on my local machine, while methods 2 and 4 take on average about twice as long.

<cfscript>
iterations = 10000;

// method 1
boolVar = 1;
timer = getTickCount();
for (i=1;i lte iterations;i = i + 1) {
if (boolVar) {
// do nothing
}
}
writeOutput("method 1: " & getTickCount() - timer & "<br>");

// method 2
boolVar = 1;
timer = getTickCount();
for (i=1;i lte iterations;i = i + 1) {
if (boolVar eq true) {
// do nothing
}
}
writeOutput("method 2: " & getTickCount() - timer & "<br>");

// method 3
boolVar = 0;
timer = getTickCount();
for (i=1;i lte iterations;i = i + 1) {
if (not boolVar) {
// do nothing
}
}
writeOutput("method 3: " & getTickCount() - timer & "<br>");

// method 4
boolVar = 0;
timer = getTickCount();
for (i=1;i lte iterations;i = i + 1) {
if (boolVar eq false) {
// do nothing
}
}
writeOutput("method 4: " & getTickCount() - timer & "<br>");
</cfscript>
```