260 likes | 427 Vues
Profiling Applications in. Luis I. Gomez. 4.18. BR 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. BR Profiler. BR Profiler Feature
E N D
Profiling Applications in Luis I. Gomez 4.18
BR 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
BR Profiler • BR Profiler Feature • Components • Profiler types • Profiling an application • Interpreting your results
BR 4.18 Profiler – Components • BR.EXE • Version 4.18+ required • PROFILER.DOC • Documentation • PROFILER.EXE • Utility to extract results.
BR 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
BR 4.18 Profiler – Types • STOP • DEBUG STOP • Stops profiling
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
Profiling an Application. • Clauses • List Clause • A clause is parsed by a ` (Not Necessarily a line)
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
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
Customizing your results. • Profiler.wb • CLS application (Available for general use) • Required BR 4.18+ • Enter the “C:\WORK\PROFILE.TXT” file
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
Customizing – 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
Customizing – 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)
Customizing – 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
Customizing – 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”
BR 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++
BR 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
BR 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!
Sample 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
Sample 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
Sample 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
Sample 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.
Sample 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)
Sample Application - Solution • How Far to Go? • Once we have 30 times improvement do we care? • 330 – “Stretchy Array” Is somewhat slow.
Profiler – Summary • Dramatically improve performance • Identify Problem Areas • Learn about the BR Internals • Extend capabilities with your own code