Home
Project Folders
Teacher Resources
Student Resources
How Do I?
Literacy
MWForum
Site Map
Search
Our Team

MWForum Message [Date Index] [Threads] [Authors] [Attachments] [Subscribe]

[Thread Prev] [Thread Next]

To: <MWcybercourse@xxxxxxxxxxxxxxx>
Subject: RE: Variables
From: "Gary McCallister" <mccallis@xxxx>
Date: Fri, 02 Nov 2001 14:39:43 -0700

Another reason to use a slider is when you are modeling and want to see 
theeffect of the variable over a range and want to run several trials in a 
row. It is tedious to type in new variables every time and that causes one to 
lose track of what is being investigated. Sliders allow one to rapidly change 
a variable and see what te difference is in the performance.

>>> wpetti@xxxx 11/02/01 01:36PM >>>
Mike, I never knew that there would be a difference in speed
between using a slider vs. a local or global variable, and I find
this very interesting.

I just ran a couple of comparison tests to see how much difference
there is. Here are the test procedures I used, and the results on
my machine.

COMPARISON 1:
(The turtle repeatedly moves forward by the amount of the variable
and draws a square over and over again. Slider's value is set to
50.)

to test_local_variable
let [x speed]
pd
resett
repeat 5000 [fd :x rt 90]
show timer
end

to test_slider
pd
resett
repeat 5000 [fd speed rt 90]
show timer
end

RESULT:
Local variable: timer =3D 153 (roughly 15 seconds)
Slider as variable: timer =3D 202 (roughly 20 seconds)

Difference in speed: It takes the turtle roughly 33% longer to
complete its task when the slider is used for the variable.

COMPARISON 2:
(The turtle adds 1 to the value with each repetition and draws a
square spiral. In the case of the slider, we see the slider's
value continually increasing. Starting value is 1. Maximum
slider value exceeds 1000 so turtle can do 1000 repetitions.)

to test_local_variable_2
let [x speed]
pd
resett
repeat 1000 [fd :x rt 90 make "x :x + 1]
show timer
end

to test_slider_2
pd
resett
repeat 1000 [fd speed rt 90 setspeed speed + 1]
show timer
end

RESULT:
Local variable: timer =3D 39 (roughly 4 seconds)
Slider as variable: timer =3D 92 (roughly 9 seconds)

Difference in speed: It takes the turtle more than twice as long
(roughly 125% longer) to complete its task when the slider is used
for the variable.

COMPARISON 2A:

When I ran the Comparison 2 test again with a different turtle
shape and a larger turtle size (160), then there was actually not
as great a difference in speed:

Local variable: timer =3D 82 (roughly 8 seconds)
Slider as variable: timer =3D 137 (roughly 14 seconds)

Difference in speed: It takes the large turtle roughly 67% longer
to complete its task when the slider is used for the variable.

In all comparisons, the turtle visually moved slower when the
slider was used as the variable.

I suppose, when deciding whether or not to use a slider as a
variable, one needs to weigh these factors:

1) number of repetitions (The difference in speed matters much
less if the task is finished in less than a few seconds in either
case.)
2) need for speed (Even with thousands of repetitions, is there a
need to maximize speed?)
3) nature of the task (Some tasks involve a greater difference in
speed than others.)
4) visualization (Is the value changing, and is there a need for
the user to see the changing value of the slider?)
5) conceptual understanding of the programmer (Is it worth
teaching this technique to beginning students of MW? If not, then
when?)

Wendy

> -----Original Message-----
> From: mike sandy [mailto:mjsandy@xxxx]=20
> Sent: Friday, November 02, 2001 2:10 PM
> To: MWcybercourse
> Subject: Variables
>
>
> MW uses the slider as a variable for transmitting
> values to a program. There can be a considerable
> gain in speed if the slider value is transferred to a
> local or global variable such as :x and this used
> in the body of the program.
> Thus:
> to start
> let [x slider.....]
> calls to procedures using :x
> end
>
> Mike



Send messages to: MWcybercourse@xxxxxxxxxxxxxxx=20
To unsubscribe, e-mail: MWcybercourse-unsubscribe@xxxxxxxxxxxxxxx=20

MWcybercourse messages are archived at:
http://groups.yahoo.com/group/MWcybercourse=20




=20

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/=20




  • Previous by thread: RE: Variables
  • Next by thread: RE: Variables

  • To save an attachment to your computer, PC users should right-click (Mac users, click and hold the mouse button) on the link and then choose 'save target as' from the pop-up menu. A window will then pop up in which you can choose a location for the file.


    © copyright 2001 - 2008