Marcos Placona Blog

Programming, technology and the taming of the web.

Month: November 2006 (page 1 of 3)

Javascript Dump?

Reading time: < 1 minute

This guy managed to create a kind of cfdump but for Javascript.

Can you imagine how many hours can be saved in Javascript debuging using this tool?

And the best thing: It’s a dump tool made by a CFDeveloper

Check it out!

Performance Test: isDefined x structKeyExists

Reading time: 2 – 2 minutes

The graphics will show it, but basically I was comparing the performance between the two of them. And guess what?

In my tests on CF7, isDefined seems to be slightly faster than structKeyExists.  The factor here is that isDefined() is super-fast when the scope exists, i.e. isDefined(“session.userID”), but really slow if a non-existent scope is used, e.g. isDefined(“unknownStruct.userID”).

However, in CF8 and Railo, structKeyExists() simply leaves isDefined() behind.

The code:

<!--- Number of iterations --->
<CFSET iterations=100000>
<!--- Looping using isDefined --->
<cfset tmp1 = getTickCount() />
<cfloop from="1" to="#iterations#" index="i">
	<cfif isdefined("")></cfif>
<cfset tmp2 = getTickCount() />
<cfset total1 = tmp2 - tmp1 />
<!--- Looping using structKeyExists --->
<cfset tmp3 = getTickCount() />
<cfloop from="1" to="#iterations#" index="j">
	<cfif structKeyExists(variables,"blog")></cfif>
<cfset tmp4 = getTickCount() />
<cfset total2 = tmp4 - tmp3 />
<!--- The cfchart --->
<cfchart format="gif" xaxistitle="function" yaxistitle="Loading Time">
	<cfchartseries type="bar" serieslabel="isDefined">
		<cfchartdata item="isDefined" value="#variables.total1#">
	<cfchartseries type="bar" serieslabel="structKeyExists">
		<cfchartdata item="structKeyExists" value="#variables.total2#">

And the results:
StructKeyExists x IsDefined

Performance Test: CFMODULE x CFIMPORT

Reading time: 2 – 2 minutes

I have about 50 files to be used as modules in a particular system. You may ask me: “Why don’t you use them as CFC’s?”
The problem is that I don’t have the time to translate all the 50 modules into a Big and Fat CFC.
We’ve been using CFMODULE to access this modules for years, but now we suddenly had to change all the file structure, and will probably have to do it again in a non distant future.
I thought about using mappings with the cfmodule, so whenever I need to change the file’s path, I could just go to the admin and change the mapping. Also I thought about using CFIMPORT, so when I need to change the path, I just go to my Application and change the path there.
I then decided to do some performance tests, and found that CFMODULE is way faster than CFIMPORT as you can see:

<!--- CFMODULE on 100 iterations --->
<cfset tmp1 = GetTickCount() />
<cfloop from="1" to="100" index="i">
    <cfmodule template="../import/test.cfm" time="#now()#">
<cfset tmp2 = getTickCount() />
<cfset totalModule = tmp2-tmp1 />
<!--- CFIMPORT on 100 iterations --->
<cfset tmp3 = getTickCount() />
<cfimport taglib="../import" prefix="mods">
<cfloop from="1" to="100" index="j">
    <mods:test time="#now()#">
<cfset tmp4 = getTickCount() />
<cfset totalImport = tmp4-tmp3 />

World Top Companies Using ColdFusion MX

Reading time: < 1 minute

Some blogs already posted it, but I found it worth posting again.

World’s Top Companies Use ColdFusion MX

Tag of the day: CFIMAGE Captcha (part 2)

Reading time: 1 – 2 minutes

as this tag does a whole bunch of things, I decided to show one more usage example.
Today I’m gonna show some captcha:

<cfimage action="captcha" fontSize="18" width="150" height="75" text="placona" difficulty="low">

Which will display something like this:
Captcha placona 1

<cfimage action="captcha" fontSize="18" width="150"
height="75" text="placona" difficulty="medium">

Displaying something like:
Captcha placona 2 

<cfimage action="captcha" fontSize="18" width="150"
height="75" text="placona" difficulty="high">

Which displays my favorite and hardest one.

Captcha placona 3
See how easy we go from very simple to very complex captchas by only changing the attribute difficulty?
Hope you liked the examples.

Older posts