|
Forum Index : Microcontroller and PC projects : CMM2 Unstructured Faster Than Structured?
| Author | Message | ||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 480 |
On the web page Calculator Performance Index There are a number of programs to measure a performance index. I ran both the unstructured BASIC version: 2 loops=1000 5 TIMER=0 10 N=1000 20 L=10 30 X=L 40 X=X+1 50 X=X-4.567E-4 60 X=X+70 70 X=X-69 80 X=X*7 90 X=X/11 100 L=L-1 110 IF L<>0 THEN 30 120 X=LOG(X) 130 X=SIN(X) 140 X=SQR(X) 150 X=SQR(X) 160 N=N-1 170 IF N<>0 THEN 20 180 PRINT X 182 T=TIMER 185 PRINT "Index:";34/T*loops 190 END and a conversion of the C program: timer=0 loops=10000 for i=0 to loops-1 r0=10 do x=r0 x=x+1 x=x-4.567e-4 x=x+70 x=x-69 x=x*7 x=x/11 r0=r0-1 loop while r0>0 x=log(x) x=sin(x) x=sqr(x) x=sqr(x) next print x t=timer print "Index:";34/t*loops The index calculated by the unstructured version was 109 The index calculated by the structured version was 122 Why such a big difference? Both were run on a CMM2 Gen 2 with overclock on and firmware version 05.07.01. Edited 2021-09-03 19:58 by toml_12953 |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10610 |
2 loops=1000 185 PRINT "Index:";T/34*loops print "Index:";34/t*loops Edited 2021-09-03 20:02 by matherp |
||||
| toml_12953 Guru Joined: 13/02/2015 Location: United StatesPosts: 480 |
Yes! Thanks. You posted while I was correcting that. The difference is about what I would expect now. That's one thing I really like about the BASIC on this machine. It's so easy to structure programs that there's no need to write spaghetti code in new programs. The structured BASIC version was trivial to convert. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |