Practice pieces


Efficency

To manage this task, you need to first understand what the core behaviour of the program is, and then edit down to that. Essentially the program:

  1. Gets the start time.
  2. Makes an array full of random ints.
  3. Prints out the sum of these ints.
  4. Gets the end time and prints how long the program has taken.

Hints:

Here's some of the efficency issues you could sort out for this:

Other inefficiencies not present include:


 

Give it a go and see if you can get it working faster. Making the changes above reduced it from 21659 milliseconds to 7 for me.

If you need more help, here's the answer (or one option, anyhow).