Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components...

26
Profiling Profiling Applications in Applications in Luis I. Gomez Luis I. Gomez 4.1 4.1 8 8

Transcript of Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components...

Page 1: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Profiling Applications inProfiling Applications in

Luis I. GomezLuis I. Gomez

4.184.18

Page 2: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR ProfilerBR Profiler• BR Profiler Feature

– Components– Profiler types– Profiling an application– Interpreting your results

• Customizing your Results– Profiler.wb– GUI editor (MyEdit or Notepad++)– Profiler.mdb

Page 3: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR ProfilerBR Profiler

• BR Profiler Feature–Components–Profiler types–Profiling an application–Interpreting your results

Page 4: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – ComponentsBR 4.18 Profiler – Components

• BR.EXE– Version 4.18+ required

• PROFILER.DOC– Documentation

• PROFILER.EXE– Utility to extract results.

Page 5: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – TypesBR 4.18 Profiler – Types

• SAMPLED– DEBUG SAMPLED C:\WORK\SAMPLED.TXT– Itemized profile of each and every execution

clause – Can be very large

• TIMED– DEBUG TIMED C:\WORK\SAMPLED.TXT– Summary of Clauses, Functions & Go Subs

– Much smaller

Page 6: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – TypesBR 4.18 Profiler – Types

• STOP– DEBUG STOP– Stops profiling

Page 7: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Profiling an Application.Profiling an Application.

• Load BR 4.18+

• Prepare for profiling– Start BR– Load desired application

• Start Profiler– You may start before the application runs– CTRL-A at a desired location– Imbed the profiler inside your application

Page 8: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Profiling an Application.Profiling an Application.

• Clauses–List Clause

• A clause is parsed by a ` (Not Necessarily a line)

Page 9: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Interpreting your results.Interpreting your results.

• PROFILER.EXE– PROFILER.EXE filename >RESULTS.TXT– PROFILER.EXE filename RAW >RAW.TXT– PROFILER.EXE filename PRETTY >PRETTY.TXT

• PROFILER.BAT– Simple Batch File to automate this complex step

Page 10: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Interpreting your results.Interpreting your results.

• DEFAULT–Simple Report with Totals

• RAW–Extracts all of the information for review

• PRETTY–Improved output over the default.

• Viewing Results–Results are Tab Delimited for easy viewing

Page 11: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing your results.Customizing your results.

• Profiler.wb–CLS application (Available for general use)–Required BR 4.18+–Enter the “C:\WORK\PROFILE.TXT” file

Page 12: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing your results.Customizing your results.

• Output Results (Tab Delimited Reports)

–Filename-Modules.txt–Filename-Results.txt–Filename-Stats.txt–Filename-Type.txt

• Source Code Results–Filename-[Full Path Name].brs

Page 13: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing – Modules.txtCustomizing – Modules.txt• Filename-Modules.txt

– Each module is assigned a #– 0 – (Unsaved) Proc or similar– 1 – Usually the “Primary program”– 2 – ?? Libraries or “Other programs”

• Other files refer to modules by #

• Nice summary– Program names– Library names

Page 14: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing – Results.txtCustomizing – Results.txt• Filename-Results.txt

– Itemized results

• Fields– Module - Module #

– Line - Program line #

– Clause - Program line clause #

– Spent - Time spent on clause

– Accrued - Total time (Timeline)

– Function - Function name (Timed)

– Gosub - Gosub name (Timed)

Page 15: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing – Stats.txtCustomizing – Stats.txt

• Filename-Stats.txt– Totals based on profiler data– Combines source code to determine

• Clause type (Print, Input, etc)

• SAMPLED– Provides statistics based on # & time

spent

• TIMED– Provides Statistics based on # of executions

Page 16: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Customizing – Type.txtCustomizing – Type.txt

• Filename-Type.txt– Totals based on profiler data– Combines source code to determine

• Clause type (Print, Input, etc)

– Statistics based on clause type

• Identify the “cost” of BR commands.

• Ignore things like “User Input”

Page 17: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – GUI EditorBR 4.18 Profiler – GUI Editor• Filename-[Full Path Name].BRS

– Complete source code extracted– List clause

• Fields– Line #– Clause– Total # times executed– Time spent (If Sampled)– Detailed clause

• Edit using MyEdit or Notepad++

Page 18: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – Profiler.mdbBR 4.18 Profiler – Profiler.mdb

• Simple MS-Access database

• Automatically links to– C:\WORK\PROFILE-MODULES.TXT– C:\WORK\PROFILE-RESULTS.TXT– C:\WORK\PROFILE-STATS.TXT– C:\WORK\PROFILE-TYPE.TXT

Page 19: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

BR 4.18 Profiler – Profiler.mdbBR 4.18 Profiler – Profiler.mdb

• How to use– Create your profile reports– Copy the results to above file names– Execute query

• This is a sample – you can be more creative!

Page 20: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample ApplicationSample Application

• PRO-SLOW.WB– Sample application parses & displays the

words used in STATUS ALL.– Takes roughly 30 seconds to execute

• Most executed– Lines 4040,4050, 3020,3040,3100

• Longest execution time– Line 3070,4040,4050,4020,321

Page 21: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample Application - ProblemsSample Application - Problems

• Poor Placement– FNSORT_WORDS

• This routine is executed many times!• Ultimately, it is only needed at the very end.• Moved to line 395

Page 22: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample Application - ProblemsSample Application - Problems

• Complex Line– 3040 – SREP & UPRC$

• One of the most executed lines• Relatively slow • Very complex & hard to read!• Move UPRC$ & break out SREP

Page 23: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample Application - ProblemsSample Application - Problems

• Longest Execution Time– 321 PRINT #

• Print is very slow in GUI Mode• No need to display 1062 Times!

– 3070 PRINT # & SUM• Print is very slow in GUI Mode• No Need to Display 7048 Times• Could be consolidated with 321• Create New Counter instead of using SUM.

Page 24: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample Application - SolutionSample Application - Solution• PRO-FAST.WB

– Application with Solutions applied– Time reduced from 30 seconds to 1

• Line 3040– WORD$=SREP$(SREP$(SREP$(TRIM$(LINE$(1:NMARKER-1)),'"',""),",",""),"_","")

– Is it Worth Faster Execution for a complex line?– Sometimes it’s actually faster to split it up.

• (Not this time)

Page 25: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Sample Application - SolutionSample Application - Solution• How Far to Go?

– Once we have 30 times improvement do we care?

– 330 – “Stretchy Array” Is somewhat slow.

Page 26: Profiling Applications in Luis I. Gomez 4.18. BR Profiler BR Profiler Feature –Components –Profiler types –Profiling an application –Interpreting your.

Profiler – SummaryProfiler – Summary

• Dramatically improve performance

• Identify Problem Areas

• Learn about the BR Internals

• Extend capabilities with your own code