[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Move Versus Let discussion



Steve,

If you compare your 3 best times for each trial, I think you
get similar results (t1 faster than t2). t0 3.10,
t1 3.76, t2 4.55.  Subtracting t0, we get t1=.66 and t2=1.45.
In this case, LET seems to be more than twice as costly as MOVE.

I used the following command lines:

   time sqr t0 / -xl -xb
   time sqr t0 / -xl -xb
   time sqr t0 / -xl -xb

"time" does the timing of the command which follows,
"-xl" says not to bother connecting to the database when running
the program, and "-xb" says not to bother printing the banner.
I leave the database connection and banner out because I don't
want to keep operating system and I/O overhead to a minimum.

I use USER instead of elapsed time to help eliminate the effects of
running on a multi-user system.  I think -xl and -xb help
with this as well (so my program doesn't have to wait for
operating system calls to complete which are associated with
the I/O related to the banner or database connect).

USER is the amount of CPU time spent in USER mode.  My unix
"time" utility reports "user", "system", and "elapsed" times.
I think "system" is the amount spent doing operating system
calls, and elapsed is total elapsed time.  On my trials, the
elapsed time varied significantly (depending on system load),
and the system time was only a few percent of the user time.

Were you using -xl and -xb?  If not, let me know whether adding
them causes your variability to come down.

Ray

> Here are the results from the test I ran on our production box, Ultra Sparc
> 6000, 10 CPU... Note the reletively wide variation in times for each test,
> I attribute this to the fact that this server is a production server with
> several Sybase servers running and other misc apps running at the same time.
>
> Each line item is the USER time from the UNIX time utility, might it have
> been better to use the REAL time?  I ran the 3 sqr's using Solaris 2.5.1
> (ksh), SQR 3.0.12.3.
>
> T0      T1      T2
>
> 3.10    7.84    4.57
> 3.10    8.06    9.13
> 6.47    3.76    4.59
> 3.11    3.78    4.57
> 3.10    3.79    4.60
> 3.14    4.43    4.58
> 6.40    8.25    4.58
> 3.13    7.82    4.55
> 6.41    8.16    4.54
> 3.09    8.17    4.55
>
> 4.11    6.41    5.03
>
> T1 - T0 = 2.30
> T2 - T0 = 0.92
>
> These results are opposite Ray's...  Not sure why, any ideas?
>
> Steve
>
> At 02:59 PM 9/8/97 -0500, you wrote:
> >In the ongoing discussion about MOVE and LET:
> >
> >I ran 3 little programs on our Pentium 100 running Linux.  We're using
> >SQR/3.0.15.
> >
> >t0.sqr runs an empty loop 1,000,000 times.
> >t1.sqr does MOVE 0 TO #dummy 1,000,000 times.
> >t2.sqr does LET #dummy = 0 1,000,000 times.
> >
> >Here are the timings (user time from "time" utility)
> >for five trials in seconds:
> >
> >     t0    t1    t2
> >    ----  ----  ----
> >    5.16  6.02  6.70
> >    5.10  6.18  6.68
> >    5.06  6.03  6.69
> >    5.09  6.06  6.70
> >    5.11  6.02  6.73
> >    ----  ----  ----
> >avg 5.10  6.06  6.70
> >
> >Subtracting out the time for the overhead of running the loop (t0),
> >we get 6.06 - 5.10 = 0.96 sec for 1,000,000 MOVEs to a numeric,
> >and 6.70 - 5.10 = 1.60 sec for 1,000,000 LETs to a numeric.
> >
> >We might reasonably conclude that for simple numeric assignments,
> >LET is 1.67 times as expensive as MOVE (on my box).
> >
> >Lots more can be investigated:
> >  How do these perform on other boxes?
> >  How do MOVE and LET compare for string assignments?
> >  What about ADD/SUBTRACT/MULTIPLY/DIVIDE?
> >  What about CONCAT/EXTRACT/FIND vs. ||/SUBSTR/INSTRING?
> >  What about UPPERCASE/LOWERCASE vs. upper/lower?
> >  What about ARRAY-ADD?
> >
> >Here are the programs I used.  One obvious improvement is
> >to do 10 MOVES/LETS per loop instead of just one.  This
> >would increase the ratio of MOVE/LET to overhead.
> >
> >t0.sqr:
> >
> >begin-program
> >do main
> >end-program
> >
> >begin-procedure main
> >move 0 to #count
> >while #count < 1000000
> >   add 1 to #count
> >end-while
> >end-procedure ! main
> >
> >t1.sqr:
> >
> >begin-program
> >do main
> >end-program
> >
> >begin-procedure main
> >move 0 to #count
> >while #count < 1000000
> >   move 0 to #dummy
> >   add 1 to #count
> >end-while
> >end-procedure ! main
> >
> >t2.sqr:
> >
> >begin-program
> >do main
> >end-program
> >
> >begin-procedure main
> >move 0 to #count
> >while #count < 1000000
> >   let #dummy = 0
> >   add 1 to #count
> >end-while
> >end-procedure ! main
> >
> >----------------------------------------------------------------------
> >Ray Ontko       |  Ray Ontko & Co  |  "Time for a new signature line."
> >rayo@ontko.com  |  Richmond, In    |  See us at http://www.ontko.com/
> >
>

----------------------------------------------------------------------
Ray Ontko       |  Ray Ontko & Co  |  "Time for a new signature line."
rayo@ontko.com  |  Richmond, In    |  See us at http://www.ontko.com/