Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Is this thing fast enough??? Post ReplyPost New Topic
Page of 3 Next >>
Author
Message << Prev Topic | Next Topic >>
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 426
Posted: 09 July 2018 at 12:49pm | IP Logged Quote Paul_L

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



Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
JohnS
Guru
Guru


Joined: 18 November 2011
Location: United Kingdom
Online Status: Offline
Posts: 1698
Posted: 09 July 2018 at 4:26pm | IP Logged Quote JohnS

Paul_L wrote:
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
Back to Top View JohnS's Profile Search for other posts by JohnS
 
panky
Guru
Guru
Avatar

Joined: 02 October 2012
Location: Australia
Online Status: Offline
Posts: 564
Posted: 09 July 2018 at 8:18pm | IP Logged Quote panky

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


__________________
DonTSM1,Duinomite,CGCMM1,CGCMM2,2xDimitech,3xWWuMites,MicksMuP,Grogster1A,4xPeterMuM+,Zonker DIP-600,3xCGuKits,CGuBoard2,SnadPic100,SCBP64 & Exp100,PMMZ144,PMMZ100 .. and loving it![:D
Back to Top View panky's Profile Search for other posts by panky
 
plover
Senior Member
Senior Member


Joined: 18 April 2013
Location: Australia
Online Status: Offline
Posts: 239
Posted: 09 July 2018 at 11:49pm | IP Logged Quote plover

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 on 09 July 2018 at 11:51pm
Back to Top View plover's Profile Search for other posts by plover
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 426
Posted: 10 July 2018 at 3:39am | IP Logged Quote Paul_L

JohnS wrote:
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
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 426
Posted: 10 July 2018 at 3:52am | IP Logged Quote Paul_L

panky wrote:
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
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
JohnS
Guru
Guru


Joined: 18 November 2011
Location: United Kingdom
Online Status: Offline
Posts: 1698
Posted: 10 July 2018 at 5:48am | IP Logged Quote JohnS

Paul_L wrote:
... 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 :)

John

Edited by JohnS on 10 July 2018 at 5:48am
Back to Top View JohnS's Profile Search for other posts by JohnS
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 426
Posted: 10 July 2018 at 10:33am | IP Logged Quote Paul_L

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
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
JohnS
Guru
Guru


Joined: 18 November 2011
Location: United Kingdom
Online Status: Offline
Posts: 1698
Posted: 10 July 2018 at 4:11pm | IP Logged Quote JohnS

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

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

John
Back to Top View JohnS's Profile Search for other posts by JohnS
 
lizby
Senior Member
Senior Member


Joined: 17 May 2016
Location: United States
Online Status: Offline
Posts: 255
Posted: 10 July 2018 at 11:51pm | IP Logged Quote lizby

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



                           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 



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 on 11 July 2018 at 12:01am
Back to Top View lizby's Profile Search for other posts by lizby
 
Paul_L
Guru
Guru


Joined: 03 March 2016
Location: United States
Online Status: Offline
Posts: 426
Posted: 11 July 2018 at 8:05am | IP Logged Quote Paul_L

@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
Back to Top View Paul_L's Profile Search for other posts by Paul_L
 
MicroBlocks
Guru
Guru
Avatar

Joined: 12 May 2012
Location: Thailand
Online Status: Offline
Posts: 2192
Posted: 11 July 2018 at 3:40pm | IP Logged Quote MicroBlocks

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.
Back to Top View MicroBlocks's Profile Search for other posts by MicroBlocks
 


Page of 3 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0, 0, 0.12