Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ProfilerInit(100) -- Initalizes the profiler, and starts the watchdog timer. Allocates memory for 100 unique function profiles. We are only using 1.
- local function ResetTimer()
- ProfilerKick()
- end
- timer.Create("ProfilerWatchdog", 1, 0, ResetTimer) -- Reset the watchdog timer every second
- -- The timer kick interval can be decreased, but very small values will start to affect performance.
- -- When this timer runs out, all time samples for each profile in memory will be written to the "profiles" folder in the root server directory.
- local loop_profile = CreateProfile("CoolLoop") -- Create a new function profile.
- function longloop()
- i = 0
- while i < 10000 do
- i = i + 1
- end
- end
- print("Test started")
- j = 0
- -- Lets get 1000 time samples for our function, and store it in the loop_profile
- while j < 1000 do
- StartProfile(loop_profile)
- longloop()
- StopProfile(loop_profile)
- j = j + 1
- end
- print("Test done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement