Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 12:32 19 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 : CMM2: V5.07.00b6 - program profiling

Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 11:56am 22 Jan 2021
Copy link to clipboard 
Print this post

Please download and try V5.07.00b6

http://geoffg.net/Downloads/Maximite/CMM2_Beta.zip

This has the following changes:

MODE 12 reverts to the original 960x540 where lines are duplicated in memory and the monitor sees 1920x1080 @ 60HZ

A new mode 14 is introduced which has the timings for 540P, still 960x540 but with no line duplication. If your monitor can handle it this is the best default mode for a widescreen monitor

The big change in this beta is a:

Program profiling capability

To turn on or off the profiling use

OPTION PROFILING ON
OPTION PROFILING OFF


This is a permanent option but it defaults to OFF whenever new firmware is loaded. With profiling on you will see a performance impact of about 5% caused by the profiling data collection which happens at the MMBasic statement level. In addition you will see a reduction in available variable RAM of 512KB. Note that profiling and OPTION RAM are mutually incompatible.

With profiling enabled you can run your programs as usual and you should see no change in behaviour other than as mentioned above. You can see the way the program has run using the commands

  Quote  LIST PROFILE
LIST PROFILE CSV






Some sample output is displayed above.
There are 5 comma-separated fields in the output

The first field is the number of times a given statement has been run
The second field is the average time in Microseconds taken to execute the statement
The third field is the crunched statement as stored in memory. This is quoted to make it easier to load into excel etc.
The fourth field is the filename in which the statement appears. This is blank if the statement is in the main program, otherwise it gives the filename of the include file in which the statement is to be found
The fifth and final field gives the line number of the statement in the source file.

When LIST PROFILE CSV is used a file is created in the same directory as the main program with the .BAS extension replaced with .CSV

LIST PROFILE can only be used at the command line
LIST PROFILE CSV can be used in a program allowing you to create and rename multiple files while a program is running if required

A program can test if OPTION PROFILING is enabled using

MM.INFO$(OPTION PROFILING)


This returns a string "On" or "Off"
Edited 2021-01-22 22:05 by matherp
 
Plasmamac

Guru

Joined: 31/01/2019
Location: Germany
Posts: 501
Posted: 01:12pm 22 Jan 2021
Copy link to clipboard 
Print this post

Wow ! Thank you Matherp
Plasma
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 01:26pm 22 Jan 2021
Copy link to clipboard 
Print this post

Hi Peter,
can be tested also MMDEBUG (MM.INFO$(OPTION MMDEBUG) = "On|Off")?
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
RetroJoe

Senior Member

Joined: 06/08/2020
Location: Canada
Posts: 290
Posted: 04:12pm 22 Jan 2021
Copy link to clipboard 
Print this post



Thanks, Peter - feels like a beta flashing weekend coming up :)
Enjoy Every Sandwich / Joe P.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 04:32pm 22 Jan 2021
Copy link to clipboard 
Print this post

  Quote  can be tested also MMDEBUG (MM.INFO$(OPTION MMDEBUG) = "On|Off")?


The question doesn't really make sense. #MMDEBUG is a pre-processor directive. If the state of the directive is OFF lines starting MMDEBUG are not loaded into memory. There is no run-time status associated with MMDEBUG. The MMDEBUG commands are either loaded into memory or not. If they are they execute. If not they don't exist as far as the run-time is concerned
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 05:03pm 22 Jan 2021
Copy link to clipboard 
Print this post

  matherp said  
  Quote  can be tested also MMDEBUG (MM.INFO$(OPTION MMDEBUG) = "On|Off")?


The question doesn't really make sense. #MMDEBUG is a pre-processor directive. If the state of the directive is OFF lines starting MMDEBUG are not loaded into memory. There is no run-time status associated with MMDEBUG. The MMDEBUG commands are either loaded into memory or not. If they are they execute. If not they don't exist as far as the run-time is concerned


The reason is, that MMDEBUG suports just simple PRINT and BREAK (still very valuable !!!), so at least such a way I can with help of condition do some other things (fox example calculate and prepare statements for debug output, which I will not use in production)

I know here will be some time penalty for doing it so and for sure better will be if MMDEBUG statement could be used as prefix for any line and when #MMDEBUG will be OFF, these lines will be not included into crunched prg...
Edited 2021-01-23 03:04 by jirsoft
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 06:40pm 22 Jan 2021
Copy link to clipboard 
Print this post

  Quote  I know here will be some time penalty for doing it so and for sure better will be if MMDEBUG statement could be used as prefix for any line and when #MMDEBUG will be OFF, these lines will be not included into crunched prg...


You can do this with #DEFINE


e.g.

#DEFINE "MYDEBUG",""
'#DEFINE "MYDEBUG","REM "
MYDEBUG print "hello"


Just uncomment the appropriate #DEFINE line depending on whether you want the line to run or not
Edited 2021-01-23 04:44 by matherp
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 01:27pm 23 Jan 2021
Copy link to clipboard 
Print this post

Thanks Peter,
it's simply perfect, this solves my problem and has not speed penalty! I need to re-read documentation...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5879
Posted: 06:02am 25 Jan 2021
Copy link to clipboard 
Print this post

Profiling is unreliable immediately after an AUTOSAVE

Using your simple example code I first did an AUTOSAVE
then <F2> to re run the program.
I also tried NEW before the AUTOSAVE but still not correct.

Every time I do subsequent runs with <F2> seem to be consistent.

> AUTOSAVE "temp.bas"
sub foobar()
local j%
j% = 0
print j%
inc j%
print j%
end sub

a=8
inc a
inc a
inc a
foobar
print a
print 'Hello World"
b=2
a=1
inc a
a = a+10
b=b\100
for i = 1 to 10
page copy 0 to 1
next i
list profile csv
end

0
1
11


> list profile
/temp.bas
        2,         1.5,  "Sub FOOBAR()",,1
        2,         2.5,  "Local J%",,2
        1,         2.0,  "J% =0",,3
        2,       513.5,  "Print J%",,4
        1,         3.0,  "Inc J%",,5
       12,        84.7,  "Print J%",,6
        1,         1.0,  "End Sub ",,7
        1,         4.0,  "A=8",,9
        1,         2.0,  "Inc A",,10
        1,         1.0,  "Inc A",,11
        1,         1.0,  "Inc A",,12
        1,         7.0,  "FOOBAR",,13
        1,      1035.0,  "Print A",,14
        1,      1009.0,  "Print ",,15
        5,         0.6,  "B=2",,16
        1,         3.0,  "A=1",,17
        1,         1.0,  "Inc A",,18
        1,         4.0,  "A =A+10",,19
        1,         4.0,  "B=B\100",,20
        1,         6.0,  "For I =1 To 10",,21
       10,      2062.2,  "Page COPY 0 To 1",,22
      493,         0.0,  "Next I",,23
       18,      2001.2,  "List PROFILE CSV",,24
        0,         0.0,  "End ",,25
> RUN
0
1
11


> list profile
/temp.bas
        1,         2.0,  "Sub FOOBAR()",,1
        1,         4.0,  "Local J%",,2
        1,         2.0,  "J% =0",,3
        1,        20.0,  "Print J%",,4
        1,         2.0,  "Inc J%",,5
        1,        17.0,  "Print J%",,6
        1,         1.0,  "End Sub ",,7
        1,         4.0,  "A=8",,9
        1,         2.0,  "Inc A",,10
        1,         1.0,  "Inc A",,11
        1,         1.0,  "Inc A",,12
        1,         7.0,  "FOOBAR",,13
        1,      1046.0,  "Print A",,14
        1,      1002.0,  "Print ",,15
        1,         4.0,  "B=2",,16
        1,         2.0,  "A=1",,17
        1,         1.0,  "Inc A",,18
        1,         4.0,  "A =A+10",,19
        1,         4.0,  "B=B\100",,20
        1,         6.0,  "For I =1 To 10",,21
       10,      2062.2,  "Page COPY 0 To 1",,22
       10,         1.2,  "Next I",,23
        1,     27072.0,  "List PROFILE CSV",,24
        1,         4.0,  "End ",,25
>


This one is also directly after an AUTOSAVE:

> list profile
/temp.bas
        2,         2.0,  "Sub FOOBAR()",,1
        2,         4.0,  "Local J%",,2
        2,         2.0,  "J% =0",,3
        2,       522.0,  "Print J%",,4
        2,         2.0,  "Inc J%",,5
        2,       518.5,  "Print J%",,6
        2,         1.0,  "End Sub ",,7
        2,         4.0,  "A=8",,9
        2,         2.0,  "Inc A",,10
        2,         1.0,  "Inc A",,11
        2,         1.0,  "Inc A",,12
        2,         7.0,  "FOOBAR",,13
        2,      1039.5,  "Print A",,14
        2,      1002.5,  "Print ",,15
        2,         3.5,  "B=2",,16
        2,         2.0,  "A=1",,17
        2,         1.0,  "Inc A",,18
        2,         4.0,  "A =A+10",,19
        2,         4.0,  "B=B\100",,20
        2,         6.0,  "For I =1 To 10",,21
       20,      2062.3,  "Page COPY 0 To 1",,22
       20,         1.1,  "Next I",,23
        2,     27015.5,  "List PROFILE CSV",,24
        2,  37262886.0,  "End ",,25
>


Jim
VK7JH
MMedit   MMBasic Help
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 08:19am 25 Jan 2021
Copy link to clipboard 
Print this post

The profiling buffer is cleared by the RUN command. Autosave doesn't use the run command so I need to add the clear to AUTOSAVE. In the meantime exit AUTOSAVE with F1 and then type RUN

UPDATE
V5.07.00b7 updated and re-uploaded
Edited 2021-01-25 19:24 by matherp
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5879
Posted: 08:59pm 25 Jan 2021
Copy link to clipboard 
Print this post

Working now with two exceptions.

The time for the END statement is ridiculously long for a run started with AUTOSAVE.
Everything else looks right.

        1,      6061.0,  "CLS ",,262
        1,         2.0,  "Page WRITE 0",,263
        1,    109271.0,  "Mode 1,8",,264
        1,       468.0,  "CLS ",,265
        1,         7.0,  "If MOUSE_PORT >=0 Then",,266
        1,      6156.0,  "Controller MOUSE CLOSE MOUSE_PORT",,267
        1,         1.0,  "GUI CURSOR OFF",,268
        1,         0.0,  "EndIf ",,269
        1, 133000785.0,  "End ",,270

        1,      6057.0,  "CLS ",,262
        1,         2.0,  "Page WRITE 0",,263
        1,    106496.0,  "Mode 1,8",,264
        1,       462.0,  "CLS ",,265
        1,         7.0,  "If MOUSE_PORT >=0 Then",,266
        1,      5942.0,  "Controller MOUSE CLOSE MOUSE_PORT",,267
        1,         1.0,  "GUI CURSOR OFF",,268
        1,         0.0,  "EndIf ",,269
        1,         4.0,  "End ",,270


The other issue is more serious.
If I turn profiling on and immediately try a AUTOSAVE, the system hangs at the conclusion of the AUTOSAVE and before the start of the program

If I do any program run before using AUTOSAVE, everything works.

It seems to happen with any program.

Jim

Edit: Make that 3 issues.
Entering LIST PROFILE at the command prompt before any code has been run, results in a system lockup.
Edited 2021-01-26 12:09 by TassyJim
VK7JH
MMedit   MMBasic Help
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024