We often need to know how long a lasts when performed by Map
We often need to know how long a lasts when performed by Maple (and by other software), i.e., how long the CPU of the computer is engaged by Maple to perform the task. This, example, can motivate for us to optimize the programming, or to whether it is worth doing it at all, or to weigh the benefits of the calculation versus and resources invested it. Find a way to time the generation of 500,000 random numbers by Maple, using the rand() command, as is shown at the beginning of the worksheet that I emailed you. Repeat for 1 million numbers, 2, 3, 4, and 5 million. Plot your results (i.e., time vs. number of random numbers) and do a polynomial fit of an appropriate order. What is the dependence of time on the number of random numbers generated?
Solution
restart: randomize(): st := time(): X:=Statistics:-RandomVariable(\'Uniform\'(0,1)): S:=Statistics:-Sample(X,5000000): for i from 1 by 1 to 5000000 do S[i]; end do: time() - st; restart: randomize(): with(RandomTools[MersenneTwister]): st := time(): for i from 1 by 1 to 5000000 do GenerateFloat(); end do: time() - st; restart: randomize(): st := time(): for i from 1 by 1 to 5000000 do rand()/(1000000000000.); end do: time() - st;