Advertisement
Techmo

GProfiler Test

Aug 25th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. ProfilerInit(1000) -- Init profiler with a maximum of 1000 function profiles
  2.  
  3. -- Create a function profile with a sample buffer of 1000 samples
  4. -- We will use this profile to tell the profiler what name we want the data stored under
  5. -- This will also be the name of the profile file in the "profiles" directory
  6. -- This profile will take up one of our 1000 maximum profiles
  7. local profile_test = CreateProfile("TestFunction")
  8.  
  9. -- Some code to profile, just adds 1 1000 times    
  10. function test_function()
  11.     local i = 0
  12.  
  13.     while i < 1000 do
  14.         i = i + 1
  15.     end
  16. end
  17.  
  18. -- Lets get 100 samples for this profile, usually the profiler would be used in the game loop
  19. -- The profiler will automatically start overwriting the oldest samples, so dont worry about using it in the game loop
  20. local j = 0
  21. while j < 100 do
  22.     print("Testing")
  23.  
  24.  
  25.     StartProfile(profile_test) -- Tell the profiler to start profiling, and store the data under "TestFunction"
  26.  
  27.     test_function() -- Call our super useful function we made, this can also just be a block of code or something
  28.  
  29.     StopProfile(profile_test) -- Tell the profiler we're done recording the data
  30.  
  31.  
  32.     j = j + 1
  33. end
  34.  
  35. -- The profiler will write the profiles to the disk when the server shuts down
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement