July 2018
Beginner
202 pages
5h 42m
English
We will implement the profiler as a new module. Create a new file, profiler.lua, and declare the profiler table. This table will contain four other tables: one table for the names of every function, one for the number of times a function is called, one for the total time spent on the function, and one for timing the functions.
The key to each of these tables is going to be a function object:
local profiler = {}profiler.names = { }profiler.counts = { }profiler.times = { }profiler.timers = { }
The profiler module will have two important public functions: start and stop. These functions will start and stop the profiler, respectively. The profiler module will have an internal function, private_hook. The start and stop functions ...