Table functions are very efficient for large data sets. One of the main reasons is b/c JMP takes advantage of multiple cores while JSL does not. However, for small data sets the process of creating the table adds a lot of overhead. For the application I am using this for, I actually had something similar to PMroz's answer, but since my lists were all <1000 items, I noticed it was adding quite a bit of time.
Thanks Everyone!
Note: Today() is only accurate to the second, Tick Seconds() is accurate to 1/60 of a second, and HP TIME() is accurate to the microsecond. Of course, this all depends on your computer. Also, to give a fair advantage, I changed your tables to private, and removed the close statement, which will speed up your script.
Names Default to Here(1);
// pmroz version
pmroz_randomizeList = Function({aList}, {Default Local},
dt = New Table( "", private,
New Column( "Data", Set Values( aList ) ),
New Column( "Randomized", Numeric, Continuous, Formula( Random Uniform() ) )
);
dt << sort(replace table, by(:Randomized));
random_list = dt:Data << get values;
);
// Jeff Perkinson Jul 13, 2016 2:00 PM (in response to Peter Mroz)
jeff_randomizeList =Function({aList},{Default Local},
aList[rank(j(nitems(aList), 1, random uniform()))]
);
// Byron's function
byron_randomizeList = Function({aList},{Default Local},
nr = nitems(alist);
rslist = random shuffle(1::nr);
blist = alist[rslist[1::nr]];
);
nm = 100; // Set the number of list elements
imax = 100; // Set number of iterations
my_list = (as list(1::nm))[1];
start = HP TIME();
For(i=1, i<=imax, i++,
randomList = pmroz_randomizeList(my_list);
);
elapsed = HP TIME() - start;
print("pmroz: " || char(elapsed));
wait(0);
start = HP TIME();
For(i=1, i<=imax, i++,
randomList = jeff_randomizeList(my_list);
);
elapsed = HP TIME() - start;
print("Jeff: " || char(elapsed));
wait(0);
start = HP TIME();
For(i=1, i<=imax, i++,
randomList = byron_randomizeList(my_list);
);
elapsed = HP TIME() - start;
print("Byron: " || char(elapsed));
wait(0);
//OUTPUT
"pmroz: 121646"
"Jeff: 3990"
"Byron: 3488"