Timing a Reporter

This lab needs a getting started...

We have seen how snap can be programmed to wait for a certain time before reporting anything. snap also allows us to do the converse: to report how long a program takes to finish. In the "Sensing" palette, you will see a command called reset timer and a reporter called timer: Reset Timer Command

  1. Activate the timer reporter (click the checkbox), and you should see a timer ticking away in the top left corner of the stage. It's been ticking ever since you opened snap, and it counts in tenths of a second:
    We are going to be performing timing experiments in the following sections, so this timer will prove useful.
    Timer ticking away
  2. Build following timing script in snap :
    Timing Framework

This script will reset the timer whenever the green flag is pressed. The sprite will say "Hello!" for 1 second, then say the current time (less 1 second to account for how long the sprite said "Hello!").

If we replace "Hello!" with a reporter, then the sprite will say the value reported by reporter, and one second later, it will say how long the reporter took to generate that response: this is the timing information that we need for the upcoming pages in this lab.

  1. "U4L3-ReporterTimer"Save your work as U4L3-ReporterTimer