Reader small image

You're reading from  Lua Quick Start Guide

Product typeBook
Published inJul 2018
Reading LevelBeginner
PublisherPackt
ISBN-139781789343229
Edition1st Edition
Languages
Right arrow
Author (1)
Gabor Szauer
Gabor Szauer
author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer

Right arrow

Profiling

Not all Lua debugging is about errors. Sometimes, debugging is more optimization work. In order to tell what part of your code is running slow, or to detect any code hot spots, you have to profile your code. Profiling code means measuring how long something took to execute, or how many times something has executed. We can use Lua's debug library to build a simple profiler.

The profile module

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Lua Quick Start Guide
Published in: Jul 2018Publisher: PacktISBN-13: 9781789343229

Author (1)

author image
Gabor Szauer

Gabor Szauer has been making games since 2010. He graduated from Full Sail University in 2010 with a bachelor's degree in game development. Gabor maintains an active Twitter presence, and maintains a programming-oriented game development blog. Gabor's previously published books are Game Physics Programming Cookbook and Lua Quick Start Guide, both published by Packt.
Read more about Gabor Szauer