Saturday, March 16, 2024

DM42 and DM41X: Timing Programs

DM42 and DM41X: Timing Programs


How Long Does it Take?

There is a convenient way of timing programs on the Swiss Micros DM42 and DM41X. This is accomplished by the TIME function. The TIME function returns the time, initially shown in HH:MM:SS format. HH represents hours, MM represents minutes, and SS represents seconds. The time is stored internally in HH.MMSS format.

We will also use the HMS- function. The HMS- subtracts two time values in HH.MMSS format.

A format that time the performance of an algorithm:


TIME

STO ## (store in any variable desired)

...

[main code here]

TIME

RCL ## (recall time stored in the beginning)

HMS-

“TIME=” (shows the time using a message, optional)

ARCL ST X

AVIEW

RTN


The elapsed time is in HH.MMSS format.


One word of caution, I would not use this method if you plan to run the test and midnight (12:00 AM or 0:00 hours) comes in between execution.



Example Code


Here is an example program that measure long a loop takes. In the example, the loop requires to display the x and y values for the function:


y = 2/5 × ln((x + 1)^2 ÷ 5) for x = 0 to 25.



Swiss Micros DM41X Code


01 LBL ^T TIMETST

02 0.025

03 STO 00

04 TIME

05 STO 01

06 LBL 00

07 RCL 00

08 INT

09 ^T X=

10 ARCL X

11 AVIEW

12 PSE

13 XEQ 01

14 ^T Y=

15 ARCL X

16 AVIEW

17 PSE

18 ISG 00

19 GTO 00

20 TIME

21 RCL 01

22 HMS-

23 ^T TIME=

24 ARCL X

25 AVIEW

26 RTN

27 LBL 01

28 1

29 +

30 X↑2

31 5

32 /

33 LN

34 2

35 *

36 5

37 /

38 RTN


Swiss Micros DM42 Code


00 {75-byte Prgm}

01 LBL “TIMETST”

02 0.025

03 STO 00

04 TIME

05 STO 01

06 LBL 00

07 RCL 00

08 IP

09 “X=”

10 ARCL ST X

11 AVIEW

12 PSE

13 XEQ 01

14 “Y=”

15 ARCL ST X

16 AVIEW

17 PSE

18 ISG 00

19 GTO 00

20 TIME

21 RCL 01

22 HMS-

23 “TIME=”

24 ARCL ST X

25 AVIEW

26 RTN

27 LBL 01

28 1

29 +

30 X↑2

31 5

32 ÷

33 LN

34 2

35 ×

36 5

37 ÷

38 RTN



The results that I have:


DM41X (SN 00843): 0.0049 (49 seconds)

DM42 (SN 03911): 0.0053 (53 seconds)


For reference, here are the values (rounded to 4 digits):


X

Y

0

-0.6438

1

-0.0893

2

0.2351

3

0.4653

4

0.6438

5

0.7896

6

0.9130

7

1.0198

8

1.1140

9

1.1983

10

1.2745

11

1.3442

12

1.4082

13

1.4675

14

1.5227

15

1.5743

16

1.6228

17

1.6685

18

1.7118

19

1.7528

20

1.7918

21

1.8291

22

1.8646

23

1.8987

24

1.9313

25

1.9627



I hope you find this helpful. Take care and until next time,


Eddie

All original content copyright, © 2011-2024. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.



Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation

  Casio fx-CG50 and Swiss Micros DM32: HP 16C’s Bit Summation The HP 16C’s #B Function The #B function is the HP 16C’s number of...