Results 1 to 2 of 2

Thread: cTimer handy for TBGL profiling

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Smile cTimer handy for TBGL profiling

    Did you downloaded the ThinBASIC 1.8.8.0? Yes? Then you can take advantage of new cTimer class.
    It is great little helper for performing precise time measurements, and it has one unique ability - it remembers its history.

    The cTimer sample in SampleScripts does not demonstrate this feature, but it is very useful one. It is represented by two methods:
    • Intermediate_Count - returning total count of measurements
    • Intermediate_Get - to retrieve nth measurement in microseconds

    With such a arsenal, you can perform the timing just by calling Elapsed method each frame and then retrieve the results later.
    The following is the part of code which serves for retrieving measurement "history". The full, executable code is attached below.
      Local sOut As String, i As Long, timeDelta As Double, frameRate As String
      
      ' -- Now we can trace back all the measured values using Intemediate_* methods
      sOut = "Frame" + $TAB + "ms" + $TAB + "FPS" + $CRLF
      For i = 1 To myTimer.Intermediate_Count       
        ' -- First item is special case, the others are just diference between i and i-1
        timeDelta = IIf(i = 1, myTimer.Intermediate_Get(1), myTimer.Intermediate_Get(i)-myTimer.Intermediate_Get(i-1))
        
        ' -- Frame rate is inverse of timeDelta, but we better check the division by zero :) 
        frameRate = IIf(timeDelta = 0, "N/A", Format$(1/timeDelta, "#.0"))                  
        
        ' -- Lets build the report
        sOut += "#" + Format$(i) + $TAB + Format$(timeDelta*1000, "#.00") + $TAB + frameRate + $CRLF   
      Next  
      
      MsgBox 0, sOut, %MB_ICONINFORMATION, "Measured frame characteristics"
    

    Petr
    Attached Files Attached Files
    Last edited by Petr Schreiber; 29-06-2011 at 20:48.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Thanks a lot Petr.

    That class is just at the beginning. A lot of new features can be added quite easily.
    If you have ideas or requests just let me know.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. New TBGL related article that r.o.c.k.s, on TBGL website!
    By Petr Schreiber in forum TBGL module by Petr Schreiber
    Replies: 6
    Last Post: 09-11-2007, 10:03

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •