Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Lua Quick Start Guide

You're reading from   Lua Quick Start Guide The easiest way to learn Lua programming

Arrow left icon
Product type Paperback
Published in Jul 2018
Publisher Packt
ISBN-13 9781789343229
Length 202 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Gabor Szauer Gabor Szauer
Author Profile Icon Gabor Szauer
Gabor Szauer
Arrow right icon
View More author details
Toc

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 €18.99/month. Cancel anytime