Created
February 4, 2015 12:46
-
-
Save Willshaw/2346d72c0dcc0063d23b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
lst = ''; | |
cnt = 10000; | |
for( i = 1; i <= cnt; i++ ) { | |
val = randRange( 1, 5 ); | |
lst = listAppend( lst, val ); | |
} | |
writeOutput( 'list has this many entries: ' & listLen( lst ) & '<br />' ); | |
// convert to distinct array using java | |
timer = getTickCount(); | |
arrDistinctVals = createObject("java", "java.util.HashSet") | |
.init( listToArray( lst ) ) | |
.toArray(); | |
writeOutput( 'java took: ' & ( getTickCount() - timer ) & '<br />' ); | |
writeDump( arrDistinctVals ); | |
skv = {}; | |
timer = getTickCount(); | |
for( j = 1; j <= cnt; j++ ) { | |
skv[ listGetAt( lst, j ) ] = ''; | |
} | |
writeOutput( 'struct took: ' & ( getTickCount() - timer ) & '<br />' ); | |
arrDistinctVals = listToArray( structKeyList( skv ) ); | |
arraySort( arrDistinctVals, "numeric" ); | |
writeDump( arrDistinctVals ); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment