Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Lua Quick Start Guide

You're reading from  Lua Quick Start Guide

Product type Book
Published in Jul 2018
Publisher Packt
ISBN-13 9781789343229
Pages 202 pages
Edition 1st Edition
Languages
Author (1):
Gabor Szauer Gabor Szauer
Profile icon Gabor Szauer

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 chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at £13.99/month. Cancel anytime}