LineProfiler - A tool to profile your code line by line (as much as it can, atleast)

Module: https://create.roblox.com/store/asset/99405784171411?viewFromStudio=true&keyword=&searchId=82b15a99-1ba6-41f8-b40e-17eaaf6993be

Just a small project, used for finding out how long each line of code actually takes.
The usage is sort of confusing, this is because this module uses metatables and methods to track the lua execution.

local lp = require(script.LineProfiler)
local function func_to_test(x)
	local count = __incl(0)
	for i=1, x do
		count += i
	end
	return count
end

local profiled = lp.ProfileFunction(func_to_test)
profiled(100)

(NOTE: this becomes easier to implement if you use tables as they’re auto tracked)
the __incl statement will include a variable’s operations in the final output.

local function table_ops(n)
	local t = __incl({})
	for i = 1, n do
		t[i] = i * 2
	end

	local sum = __incl(0)
	for i = 1, n do
		sum += t[i]
	end
	return sum
end

Shown is the output of a profiled function for a small project im working on.
image


The hits table show how many times a certain line of code has been executed, and the TimeSpent shows the time spent on that line.

Also, all arguments are auto-tracked (to the function)

If you need any help using the module, let me know!

3 Likes

This looks cool, I’ll keep it around for the future

1 Like


Asset is not available unfortunately.

should be working now so try again

It still isn’t for me. But it may be an issue on my side.


seems roblox doesnt like it, this is probably because the script profiles the entire environment too through getfenv and setfenv.
Here is the github: GitHub - YesilHiyar/LineProfiler: A simple line by line profiler for Roblox