1 / 8

Timing Code & Profiling

Timing Code & Profiling. Timing. Method 1 : Stop watch Measure real "wall" time from start to end Other processes may have very direct impact. Instrumented Timing. Method 2 : instrument code Add code to record elapsed processor time between points in code Targeted timing. < ctime >.

ward
Download Presentation

Timing Code & Profiling

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Timing Code & Profiling

  2. Timing • Method 1 : Stop watch • Measure real "wall" time from start to end • Other processes may have very direct impact

  3. Instrumented Timing • Method 2 : instrument code • Add code to record elapsed processor time between points in code • Targeted timing

  4. <ctime> • <ctime> library includes • clock() : units of time since program launch • 1ms with win32 g++ • c_type : type of data returned by clock() • typedef of long on win32 g++ • CLOCKS_PER_SECOND : defined value • Integral type – careful with division

  5. Timing Issues • On Windows, clock() measures wall time elapsed • On linux processor time elapsed • Hard to measure short events • Wrap in a loop and average

  6. Short Events • If loop dominates work being done • Compare loop with and without body

  7. Code Profiling • Method 3 : Profiling • Run time analysis of code execution • Call graph • Track each function call, where it came from • Sampling • Periodically stop program, check where it was

  8. gprof • gprof : Gnu Profiler • Simple profiling tool that ships with mingw compiler suite • Limitation • Call times are estimates – assume every function call equally expensive • Only measures time spent by your process • Ignores time spent in syscalls

More Related