Download or view mapTimeTest.frink in plain text format
// This program tests the performance of calling map[f,list] as opposed to
// just calling the function repeatedly.
a = makeArray[[million], 1]
double[x] := x + x
doubleFunc = getFunction["double", 1]
for loop = 1 to 5
{
results = new array
start = now[]
for item = a
results.push[double[item]]
end = now[]
println["Call, no print: " + ((end-start) -> "ms")]
start = now[]
for item = a
double[item]
end = now[]
println["Call, no push: " + ((end-start) -> "ms")]
start = now[]
results = map[doubleFunc, a]
end = now[]
println["Map: " + ((end-start) -> "ms")]
println[]
}
Download or view mapTimeTest.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20145 days, 19 hours, 40 minutes ago.