What is "debug.profilebegin" and "debug.profileend"?

I came across these 2 functions (read the title) however the studio website does not specify what they do. Can someone explain to me what they do with examples?

2 Likes

They show how long it took to perform a certain task in the microprofiler. This is used for locating performance issues and fixing them. Run debug.profilebegin() at the start of some code with an argument of what you want the name to appear in the microprofiler as. Then run debug.profileend() at the end of your code with that same name argument. You’ll be able to determine how long and how performance heavy that code was.

5 Likes

Please consult the Developer Hub first before posting threads on API. It is explained on the article exactly what these do and you could logically also search for related articles on the MicroProfiler by connecting the dots: profilebegin/end open MicroProfiler labels, search what the MicroProfiler is.

https://developer.roblox.com/en-us/api-reference/lua-docs/debug
https://developer.roblox.com/en-us/articles/MicroProfiler

As for use examples, please again search before posting, as there already are some samples here. Take for example the following code that opens a label for a 1000-iteration for loop performance test:

1 Like

mine is an error in the output box pls help

Create a new topic on your issue rather than bumping an old thread

ok ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎ ‎‎‎