The ComputationMonitor demo opens a window with several labels
and text fields, two radio-buttons and a push-button.
To run a quick demo, just press the push-button "Start computation",
leaving the built-in settings.
A new window opens, with a check-box and a disabled push-button.
Pressing several times the check-box "Pause",
the computation alternatively suspends and resumes.
Pressing the push-button "Kill job" when the computation is suspended,
the computation ends and the secondary window closes.
The fields in the primary window are the following:
Remote host name: The DNS host name or the IP address
of the host where the server is running.
If the server is on the same host, it is also possibile
to specify "localhost" or "127.0.0.1". To run a local computation,
i.e. an in-process computation, leave this field empty.
Stage count: The number of parts that compose the computation job.
A simple computation has only one stage, but a complex one
could have several stages (for instance: load, sort, compare,
verify, store).
Running time per stage: The time (in milliseconds)
taken by every single stage.
Initial unresponsiveness time: The time (in milliseconds)
at the begin of every stage in which the computation does not
respond to the compuntation monitor. During such time,
the "pause" command is not effective and the progress bar
does not advance.
Inner unresponsiveness time: The time (in milliseconds)
of every slice of computation,
after the initial unresponsiveness time of every stage,
in which the computation does not respond
to the computation monitor.
Iteration count: The number of times that a computation
will be executed.
Busy wait: The time slice of the computation is a tight loop
that checks continually the current time. With this option,
the computation consumes every available CPU cycle.
Idle wait: The time slice is a call to the "sleep" method.
With this option, the computation consumes few CPU cycles.
Work time: The sum of the time slices of the computation.
If the computation is not aborted, it is equal to or a little
greater than the stage count multiplied by the running time
per stage. The rounding errors add up at every stage,
so with many stages and an inaccurate system clock,
the total error can exceed one second.
Iterations done: The effective number of iteration completed
by the last computation.
Average time per iteration: The total real time of the computation
divided by the number of iterations done. It is approximately equal
to the work time plus the time elapsed at every pause.
Try the following combinations, keeping the default values
for the other fields:
Stage count=5, Running time per stage=4000.
The monitor shows 5 stages.
Stage count=10, Running time per stage=300.
The monitor doesn't appear, as the estimated total time is too short.
The estimate is done using the time-to-progress ratio
of the first-level computation (in this case, the stage level).
With these values, at the first check, 400 ms are passed,
and only one stage of ten has completed,
so the estimated completion time is 400 ms/Stage x 10 Stages = 4000 ms,
that is less than the limit of 5000 ms.
If the stage count were 15, the monitor would appear,
as the the estimated completion time would be 400 x 15 = 6000.
Initial unresponsiveness time=8000. When the window appears,
press the "Pause" check-box. The computation continues
until it reaches 40%, when the unresponsiveness has ended.
Afterwards, the "Pause" command is responsive.
Busy wait or Idle wait. Use a CPU monitor to compare the CPU usage.
In the client/server case with the busy wait option,
only the server host uses up CPU cycles.
Running time per stage=0, Inner unresponsiveness time=1,
Iteration count=500. An empty empty computation is repeated 500 times.
The average time per iteration shows the overhead.
Of course, in the client/server case
the overhead is much bigger than in the local case.
Caution: If you set a very long unresponsiveness time
for a long computation, you will not be able to terminate that computation.
For instance, if you set Running time per stage=3600000 (i.e. an hour)
and Initial unresponsiveness time=600000 (ten minutes),
your supension command will take effect only ten minutes after
the start of the computation.
Caution: The "Kill job" command, terminates only the current
computation, so, if you set a big iteration count, you will not be able
to terminate all the iterations.
For instance, if you set Running time per stage=1000 (i.e. one second)
and Iteration count=600, you will have to wait ten minutes
before completion.
Tip: If you inadvertently launched a computation that you can't stop,
go to the console window where you started it, and press Ctrl+C.