Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 00:03 20 Apr 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Is this thing fast enough???

     Page 1 of 3    
Author Message
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 02:49am 09 Jul 2018
Copy link to clipboard 
Print this post

You bet it is!!!! I'm amazed at the speed Geoff has wrung out of MMBasic. The DOS implementation beats the speed produced by Visual Studio FoxPro which is a P code compiler. It almost matches the speed produced by fully compiled Clipper.

But, I'm writing a program to control a geothermal heating system in real time in which control delays can't be tolerated, but it has to manipulate a lot of strings, read some calibration data from a file, and log a lot of data to disk. I'm writing the thing under DOS because I don't really know how fast or big a PIC chip I need to run it.

I needed some hard data about the relative speed of the available PIC chips versus the PC on which I'm writing the program so I wrote this program. Some of the forum members might be interested in it so I'm posting it here.

TA.ZIP contains TA.BAS, TAIN.TXT and TAOUT.TXT. Keep them all together in the same directory. TA.BAS will read input strings repetitively from TAIN.TXT.

You will be asked to type in a computer description for identification of the output data which will be appended to TAOUT.TXT. TA.BAS will add the new running times to TAOUT.TXT every time you run it. Please preserve the new TAOUT.TXT file and post it back here for mutual analysis of the running times which you observe.

TA.BAS will write 1,000,000 lines into a 47MB file, TAJUNK.TXT, which should be discarded after the test. Make sure that the disk or SD card you run it on has enough free space for this file before starting.

TA.BAS runs five loops as follows:
1. 1,000,000 repetitions of an empty loop
2. 10,000 repetitions of a loop which reads 100 lines from TAIN.TXT
3. writes a new TAJUNK.TXT file containing 1,000,000 lines of text
4. 900,000 repetitions of a loop which extracts a MID$() from a string
5. 1,000,000 repetitions of a loop which takes a VAL() from a string

Grogster ran it on his desktop, an MM+ and an MMX. This table lists the program running times in milliseconds for all of the tests so far.


i5 Celeron MMX MMX MM+ MM+
5GHz 2GHz 252MHz 200MHz 120MHz 100MHz
1 empty loop 266 844 5109 6477 13532 16257
2 read file 7047 19219 170491 202206 491706 565035
3 write file 2891 8203 189127 189466 325843 365102
4 mid$(x$) 1906 6125 51147 64282 119408 143456
5 val(x$) 1391 4157 26971 33824 70604 84823
6 rel clock period 1.0 2.5 79 100 166 200


The strange thing about these times is that they are not inversely proportional to the clock speeds and the number of cores. The times for the PIC chips are about 1/3 of what you would expect. I suspect that it is the windoze times which are 3 times what they should be.

' ta.bas, written by P Lepkowski, 7/8/2018, for public domain use

Cls
Print "TA.BAS determines the running time for repetitive actions"
Print "running under the MMBasic inerpreter on different CPUs."
Print
Print "It was written to establish the comparative processing speeds"
Print "of the MM, MM+, MMX, and DOS environments for intensive string"
Print "and file handling routines which will give you some relative idea"
Print "of the processing speed in the PIC environment after you test"
Print "string intensive routines under DOS."
Print
Print "TAIN.TXT should be placed in the same directory as TA.BAS."
Print "TA.BAS will read input strings repetitively from TAIN.TXT."
Print
Print "TA.BAS will ask you to type in a computer description for identification"
Print "of the output data which will be appended to TAOUT.TXT. Please preserve"
Print "the TAOUT.TXT file and post it back here for mutual analysis."
Print
Print "TA.BAS will write 1,000,000 line into a 47MB file, TAJUNK.TXT, which"
Print "can be discarded after the test. Make sure that the disk or SD card"
Print " has enough free space for this file before starting."
Print
Print "TA.BAS runs five loops as follows:"
Print " 1. 1,000,000 repetitions of an empty loop"
Print " 2. 10,000 repetitions of a loop which reads 100 lines from TAIN.TXT"
Print " 3. writes a new TAJUNK.TXT file containing 1,000,000 lines of text"
Print " 4. 900,000 repetitions of a loop which extracts a MID$() from a string"
Print " 5. 1,000,000 repetitions of a loop which takes a VAL() from a string"
Print
Print "The program runs in about 14 seconds on my Dell I5 3.4 GHz desktop."
Print
Print "Please input a description of this computer or a null string to Cancel."
Line Input " .... ?",cn$
Print cn$
If cn$="" Then Print "Cancelled.":End

On error skip
Open "tain.txt" For input As #1
If MM.Errno>0 Then
Print
Print "I can't continue because I can't open the required TAIN.TXT file."
Print "Please copy the TAIN.TXT file into the current directory and try again."
End
EndIf
Close #1

t$="101.1222.2333.3444.4555.5666.6777.7888.8999.9"
in$="":pp$=" ms per iteration.":ms$="ms or "
Open "taout.txt" For append As #2 'append as #2
Open "tajunk.txt" For output As #3
b$="Running on computer '"+cn$+"' on "+Date$+" at "+Time$
Print b$:printz(b$)
sa=Timer

nam$="1,000,000 iterations of empty loop":printpa
s1=Timer:For i=1 To 1000000:Next:s1t=Timer-s1:s1to=s1t/1000000:printpb

nam$="reading 100 line file 10,000 times":printpa
s1=Timer:readfile:s1t=Timer-s1:s1to=s1t/1000000:printpb

nam$="writing 1,000,000 line file":printpa
s1=Timer:printfile:s1t=Timer-s1:s1to=s1t/1000000:printpb

nam$="parse 9 strings from 100,000 strings":printpa
s1=Timer:parselines:s1t=Timer-s1:s1to=s1t/900000:printpb

nam$="extracting the value from a string 1,000,000 times":printpa
s1=Timer:extractvalues:s1t=Timer-s1:s1to=s1t/1000000:printpb

sat=Timer-sa:sato=sat/4900000
b$="Finished 4,900,000 iterations on computer '"+cn$+"' in "+Str$(sat,2)+ms$+Str$(sato,0,4)+pp$
Print b$:printz(b$)
b$="==============================================="
Print b$:printz(b$)
Close #2:Close #3
End

Sub printfile
Local t$="101.1222.2333.3444.4555.5666.6777.7888.8999.9"
For i=1 To 1000000
Print #3,t$
Next
End Sub 'printfile

Sub readfile
For i=1 To 10000
Open "tain.txt" For input As #1
For j=1 To 100 '900
Line Input #1, in$
Next j
Close #1
Next i
End Sub 'readfile

Sub parselines
Local t$="101.1222.2333.3444.4555.5666.6777.7888.8999.9"
For i=1 To 100000
For j=1 To 9
v$=Mid$(t$,((j-1)*5)+1,5)
Next j
Next i
End Sub 'parseline

Sub extractvalues
Local t$="222.2", v=0
For i=1 To 1000000
v=Val(t$)
Next
End Sub 'extractvalues

Sub print42
Print #2," A = "; Str$(a,2);" B = "; Str$(b,2);
Print #2," C = "; Str$(c,2);" D = "; Str$(d,2);
Print #2," loop 4 time = ";Str$(sdt,2);ms$;Str$(sdto,0,4);pp$
End Sub 'print42

Sub printpa
b$="Starting "+(nam$)+" ... ":? b$:printz(b$)
End Sub 'printpa

Sub printpb
b$="Finished "+nam$+" in "+Str$(s1t,2)+ms$+Str$(s1to,0,4)+pp$
Print b$:printz(b$):printz("")
End Sub 'printpb

Sub printz(p$)
Print #2,p$:? #3,p$
End Sub 'printz()


2018-07-09_123300_ta.zip

Paul in NY
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 06:26am 09 Jul 2018
Copy link to clipboard 
Print this post

  Paul_L said   It almost matches the speed produced by fully compiled Clipper.

But, I'm writing a program to control a geothermal heating system in real time in which control delays can't be tolerated, but it has to manipulate a lot of strings, read some calibration data from a file, and log a lot of data to disk. I'm writing the thing under DOS because I don't really know how fast or big a PIC chip I need to run it.


First a nitpick: Clipper is not a complier (yes, I know they said it was). It does a far better job than the crude P-code interpreters, though.

For your intended application you may want to split the file I/O onto a separate board so it can be overlapped with the control logic.

John
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1094
Posted: 10:18am 09 Jul 2018
Copy link to clipboard 
Print this post

Paul,

Interesting! Could you expand a little on what string manipulation is involved in your geothermal controller? Also, what amount of data is to be logged over what time?

Could a multiple MM system be your answer? An MMX or STM as the real time controllers with perhaps CFunctions doing the string manipulation and dump the logging data to a PC together with system status?

Just some thoughts ☺☺
panky

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
plover

Guru

Joined: 18/04/2013
Location: Australia
Posts: 302
Posted: 01:49pm 09 Jul 2018
Copy link to clipboard 
Print this post

I happened to be working in the DOS version on my hp8300 and decided to figure out how to run the program, I have added my values in the table, the actual output in the terminal next section.

i5 Celeron MMX MMX MM+ MM+ hp833sff
5GHz 2GHz 252MHz 200MHz 120MHz 100MHz 3GHz
1 empty loop 266 844 5109 6477 13532 16257 312
2 read file 7047 19219 170491 202206 491706 565035 7363
3 write file 2891 8203 189127 189466 325843 365102 3292
4 mid$(x$) 1906 6125 51147 64282 119408 143456 2013
5 val(x$) 1391 4157 26971 33824 70604 84823 1435
6 rel clock period 1.0 2.5 79 100 166 200 1.67



Running on computer 'hp8300-elite-smff‚‚ff-3ghzGHz' on 09-07-2018 at 08:20:07
Starting 1,000,000 iterations of empty loop ...
Finished 1,000,000 iterations of empty loop in 312ms or 0.0003 ms per iteration.

Starting reading 100 line file 10,000 times ...
Finished reading 100 line file 10,000 times in 7363ms or 0.0074 ms per iteration.

Starting writing 1,000,000 line file ...
Finished writing 1,000,000 line file in 3292ms or 0.0033 ms per iteration.

Starting parse 9 strings from 100,000 strings ...
Finished parse 9 strings from 100,000 strings in 2013ms or 0.0022 ms per iteration.

Starting extracting the value from a string 1,000,000 times ...
Finished extracting the value from a string 1,000,000 times in 1435ms or 0.0014 ms per iteration.

Finished 4,900,000 iterations on computer 'hp8300-elite-smff‚‚ff-3ghzGHz' in 14445ms or 0.0029 ms per iteration.
Edited by plover 2018-07-10
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 05:39pm 09 Jul 2018
Copy link to clipboard 
Print this post

  JohnS said  First a nitpick: Clipper is not a complier (yes, I know they said it was). It does a far better job than the crude P-code interpreters, though.

For your intended application you may want to split the file I/O onto a separate board so it can be overlapped with the control logic.

Hi John, you're right about Clipper, it was not really a full fledged compiler, it didn't go all the way to machine code, it stopped with p-code and linked it into .obj modules, but it was fast as lightning. I worked on that thing with Brian Russel. I still have most of the source code on this machine, (a mix of assembler, B and C), for the Summer '85 version. I was disappointed when Barry Rebell sold to CA, I thought we could make it work under windows, but he got $190 million for it, so I guess it was the right decision. I don't know why CA gave up on adapting it to windows. I guess the market just wasn't big enough for them and most of their business was in IBM mainframe management.

MMBasic is the surprise, I actually compiled that code with Clipper '87 and it ran in about 78% of the time for the MMBasic interpreter. That's unbelievable! Geoff did an amazing job with MMBasic.

Splitting the i/o to another board is not a good idea. The comm code with handshaking will take more time than the direct display. User setting changes will be infrequent.

Paul in NY
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 05:52pm 09 Jul 2018
Copy link to clipboard 
Print this post

  panky said  Interesting! Could you expand a little on what string manipulation is involved in your geothermal controller? Also, what amount of data is to be logged over what time?

Could a multiple MM system be your answer? An MMX or STM as the real time controllers with perhaps CFunctions doing the string manipulation and dump the logging data to a PC together with system status?

To conserve memory I encode floating point variables into formatted string arrays using STR$(v,n,d) a lot and store them on an SD card. The SD card file will have to be dumped out to a PC for analysis every week or so. I doubt that I will be able to use RF. This is a noisy location for RF. The PC will probably be tethered or I will unplug the SD card briefly.

The actual processing speed is not critical. The machinery is slow to respond to changes and the DS18B20 sensors will take 800 ms to do the AtoD conversions. I will probably wind up using an MMX because I need a lot of pins to switch all the high power motor relays. I might use zero crossing optocouplers driving triacs.

Paul in NY
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 07:48pm 09 Jul 2018
Copy link to clipboard 
Print this post

  Paul_L said   ... but he got $190 million for it

Splitting the i/o to another board is not a good idea. The comm code with handshaking will take more time than the direct display. User setting changes will be infrequent.

Paul in NY

Ye gods! I'd no idea he got anything like so much!!

Should've provided money for the food he (apparently) consumed LOL

It seemed like you wanted to do disk I/O and I figured that would be slow, whereas you could hand the actual data across to another board very quickly.

Display speed will depend which kind :)

JohnEdited by JohnS 2018-07-11
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 12:33am 10 Jul 2018
Copy link to clipboard 
Print this post

John, look at the numbers! The disk write speeds are probably faster than a wired async link would be. The display requirements are very slow. It will have to update 10 numbers once every 15 seconds or so.

Paul
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 06:11am 10 Jul 2018
Copy link to clipboard 
Print this post

If you're happy, that's good enough.

(You can do board-to-board very very fast, though.)

John
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3008
Posted: 01:51pm 10 Jul 2018
Copy link to clipboard 
Print this post

Paul--you could look at the numbers for the Armmite - STM32H7.

Here is a set of benchmarks from here, with STM32H7 added:
https://www.thebackshed.com/forum/forum_posts.asp?TID=4685&KW=benchmark&PN=1&TPN=2

[code]

BM1 BM2 BM3 BM4 BM5 BM6 BM7 BM8
ABC 800 single precision 0.9 1.8 6.0 5.9 6.3 11.6 19.6 2.9
ABC 800 double precision 1.2 2.2 10.0 10.6 11.0 17.8 26.4 14.4
IBM PC 1.5 5.2 12.1 12.6 13.6 23.5 37.4 3.5
Apple III 1.7 7.2 13.5 14.5 16.0 27.0 42.5 7.5
VIC-20 1.4 8.3 15.5 17.1 18.3 27.2 42.7 9.9
ZX81 in "fast mode" 4.5 6.9 16.4 15.8 18.6 49.7 68.5 22.9

Maximite 0.016 0.144 0.196 0.205 0.354 0.512 0.721 0.310

Maximite with line Nos 0.016 0.131 0.193 0.194 0.245 0.393 0.582 0.241
Maximite without line Nos 0.016 0.111 0.173 0.173 0.192 0.336 0.525 0.220
MicroMite 40MHz 0.028 0.18 0.285 0.289 0.644 0.892 1.346 0.376
MicroMite 48MHz 0.023 0.15 0.237 0.24 0.536 0.744 1.121 0.313
Picromite Pi Zero 0.014 0.058 0.093 0.102 0.184 0.298 0.354 0.127
Armmite STM32H7 0.003 0.023 0.038 0.042 0.067 0.098 0.146 0.065

C-Language (code see above):
Arduino UNO 0.010 0.010 0.058 0.043 0.043 0.043 0.045 0.284
Arduino DUE 0.003 0.003 0.006 0.007 0.007 0.007 0.106 0.014


[/code]
Armmite STM32H7 numbers from here:
https://www.thebackshed.com/forum/forum_posts.asp?TID=10568&PN=1

You might try running these benchmarks on MM for DOS, though they don't replicate your writing to SD card example.

Edit: picromite added from here:
https://www.thebackshed.com/forum/forum_posts.asp?TID=9546&KW=benchmark
Edited by lizby 2018-07-12
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 10:05pm 10 Jul 2018
Copy link to clipboard 
Print this post

@lizby - Hi Lance. You're completely correct in taking a look at the Armmite. I like the idea of the ARM core, the more easily relocatable compiler output, and the higher speed a lot. So I downloaded the pinout spreadsheet for the really gorgeous Nucleo board from that thread and now I'm bumfuzzled.

It doesn't seem to have many general purpose I/O pins which can be used for DS18B20 temperature sensors, counting inputs from flow sensors, and relay control output. The porting of the MMBasic language to the ARM core is progressing very well. I am sure that Peter Mather will solve all of the problems which will appear.

In terms of my project the benchmarks I presented above seem to indicate that, with some small adjustments, the MM+ is capable of doing the job nicely, however I may have to settle on the faster MMX in order to obtain more I/O pins. It also seems that the PIC implementation is extremely reliable and bug free.

I know that near future developments will definitely produce a better choice, but I have to get this gizmo running soon. I think I had better concentrate on an MMX implementation, unless you can tell me that the Nucleo board will accomodate all my I/O needs.

Paul in NY
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 05:40am 11 Jul 2018
Copy link to clipboard 
Print this post

If speed is important then it seems the Arduino DUE beat all the others.
Sure it is C, but with hundreds of library functions available you need only to learn a few core concepts of C and you are ready to go. Lots of IO also available. Cost very low. Support possibilities enormous.

Microblocks. Build with logic.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5882
Posted: 06:40am 11 Jul 2018
Copy link to clipboard 
Print this post

On the Nucleo STM32

Running on computer 'nucleo' on 11-07-2018 at 16:00:00
Starting 1,000,000 iterations of empty loop ...
Finished 1,000,000 iterations of empty loop in 1519ms or 0.0015 ms per iteration.

Starting reading 100 line file 10,000 times ...
Finished reading 100 line file 10,000 times in 369262ms or 0.3693 ms per iteration.

Starting writing 1,000,000 line file ...
Finished writing 1,000,000 line file in 566168ms or 0.5662 ms per iteration.

Starting parse 9 strings from 100,000 strings ...
Finished parse 9 strings from 100,000 strings in 30291ms or 0.0337 ms per iteration.

Starting extracting the value from a string 1,000,000 times ...
Finished extracting the value from a string 1,000,000 times in 16175ms or 0.0162 ms per iteration.

Finished 4,900,000 iterations on computer 'nucleo' in 983431ms or 0.2007 ms per iteration.
===============================================

VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 07:34am 11 Jul 2018
Copy link to clipboard 
Print this post

  Quote  I think I had better concentrate on an MMX implementation, unless you can tell me that the Nucleo board will accomodate all my I/O needs.


The Armmite has 91 general purpose I/O of which 26 are analogue capable, 8 support PWM, 5 support count. Any of the 91 can be used for DS18B20, relays etc
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 08:29pm 11 Jul 2018
Copy link to clipboard 
Print this post

Well .... food for thought!

@Jim - Thanks, that data is very interesting. Here's a synopsis of the test results (in milliseconds) thus far.

loop read file write file mid$() val() total
Dell i5 3.4GHz 266 7047 2891 1906 1391 13516
Cel Quad 2GHz 844 19219 8203 6125 4157 38579
MM+ @ 100MHz 16257 565035 365102 143456 84823 1174760
MM+ @ 120MHz 13532 491706 325843 119408 70604 1021110
MMX @ 200MHz 6477 202206 189466 64282 33824 496432
MMX @ 252MHz 5109 170491 189127 51147 26971 442913
nucleo 1519 369262 566168 30291 16175 983431

The nucleo is faster than the MMX in the empty loop (3x+), mid$() and val() (<2x), but is slower than the MMX reading the file (<0.5x) and writing the file (0.3x). The nucleo is even slower than the MM+ when writing the file. The file handling parts of the nucleo code seem to be extremely inefficient. I wonder if the slow speed comes from the disk file handling or from the Print #n MMBasic implementation.

@Peter - 91 I/O pins ... that's a lot of I/O! Is that for the chip or for the nucleo board? How easy would it be to adapt a nucleo board to a big touch display and still be able to get the I/O pins out to a breakout board to connect to D-Sub Amphenol cables? That professional nucleo board sure is pretty! What do you think about the nucleo and the ARM core? Will it be as reliable as a PIC? How difficult will it be to write periodic data to an SD card and occasionally either remove the card or dump the data to a tethered PC?

I wonder if the higher processing speed in the math functions will compensate for the slower disk file handling speed in my application.

Thanks for your thoughts everyone!

Paul in NY
Edited by Paul_L 2018-07-13
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5882
Posted: 11:31pm 11 Jul 2018
Copy link to clipboard 
Print this post

File read/write is up to the speed of the SDcard. I am having trouble with my setup so it might not be typical.

I was please that I was able to get the file system to work at all.

Jim
VK7JH
MMedit   MMBasic Help
 
Paul_L
Guru

Joined: 03/03/2016
Location: United States
Posts: 769
Posted: 03:19am 12 Jul 2018
Copy link to clipboard 
Print this post

Hi Jim,

Are you saying that there is that much variability in the speed of SD cards?

A fast card will take 189127 ms writing that monster file under an MMX, then a slow card will take 566168 ms under a nucleo?

That doesn't sound reasonable.

Paul in NY
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5882
Posted: 04:35am 12 Jul 2018
Copy link to clipboard 
Print this post

SD speed standards:
https://www.sdcard.org/developers/overview/speed_class/

Jim
VK7JH
MMedit   MMBasic Help
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3649
Posted: 07:17am 12 Jul 2018
Copy link to clipboard 
Print this post

  Paul_L said   Are you saying that there is that much variability in the speed of SD cards?

Yes. There's a big difference.

A bit like hdd compared to a floppy.

John
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8567
Posted: 07:27am 12 Jul 2018
Copy link to clipboard 
Print this post

  Quote  The nucleo is even slower than the MM+ when writing the file. The file handling parts of the nucleo code seem to be extremely inefficient.


The STM library routines are inefficient particularly when doing individual character I/O which is how MMBasic works and the test program magnifies that. They are faster when doing larger transfers such as loading an image.

 
     Page 1 of 3    
Print this page
© JAQ Software 2024