Skip to content

Instantly share code, notes, and snippets.

@JamoCA
Last active November 18, 2022 19:54
Show Gist options
  • Save JamoCA/1e9b424d0f4f401984ae60d127d96215 to your computer and use it in GitHub Desktop.
Save JamoCA/1e9b424d0f4f401984ae60d127d96215 to your computer and use it in GitHub Desktop.
Comparison of ListFindNoCase versus ListFind w/lcased values or pre-optimized values
<!--- 2022118 Comparison of ListFindNoCase versus ListFind w/lcased values or pre-optimized values
Tweet: https://twitter.com/gamesover/status/1593692201363521536
---->
<cfscript>
a = "A,B,c,d,E,f,g,H,I,J,l,m,n,O,p,Q,R,S,t,u,v";
s = "S";
iterations = 1000000;
t = gettickcount();
for(i=0; i lte iterations; i+=1){
listfindnocase(a, s);
}
writeoutput("listfindnocase: #val(gettickcount()-t)#<br>");
t = gettickcount();
for(i=0; i lte iterations; i+=1){
listfind(lcase(a), lcase(s));
}
writeoutput("listfind w/lcase: #val(gettickcount()-t)#<br>");
a2 = lcase(a);
s2 = lcase(s);
t = gettickcount();
for(i=0; i lte iterations; i+=1){
listfind(a2, s2);
}
writeoutput("listfind w/pre-lowered: #val(gettickcount()-t)#<br>");
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment