Hello devs, I know how to use tick() if that is related to os.time. Any help is appreciated!
The Roblox Developer website provides documentation on how these functions work, as well as how to use them.
os.time()
is basically the same as doing os.tick()
(Returns the amount of seconds since the “Unix epoch”), except it returns back the seconds relevant in UTC Time
os.date()
however can be used to recieve back a Dictionary full of the dates, provided you have a given timestamp
-- September 16th, 1998 at 11:48:10 PM:
local timestamp = 906000490
local t = os.date("*t", timestamp)
-- Produces the following table, t:
-- {year = 1998, month = 9, day = 16, yday = 259, wday = 4,
-- hour = 23, min = 48, sec = 10, isdst = false}
How can you print to see that on console?
I think there is a print function
How do I use os.clock function?
os.clock()
seems to return back the amount of CPU time when using Lua Programming in seconds
Not sure how you’d use it, but the example provides that you could use it to detect performance-based issues possibly
-- Record the initial time:
local startTime = os.clock()
-- Do something you want to measure the performance of:
local a, b = 0, 1
for i = 1, 5000000 do
a, b = b, a
end
-- Measure amount of time this took:
local deltaTime = os.clock() - startTime
print("Elapsed time: " .. deltaTime)
--> Elapsed time: 0.044425600033719 (actual number may vary)
What is CPU time in Lua? Is it pc time?
Also I understand os.date, os.difftime and os.time just missing os.clock
I believe it’s just the amount of time you’ve been using Lua’s programming language in total (Etc opening up a Script)
It’s either that or it’s your total time spent on ROBLOX Studio in general
You mean how many seconds lua is taking up?
CPU Time is the amount of time an application has been running a set of computer instructions using the Central Processing Unit. I can’t put it into words, so here:
Is os.clock used to measure performances?
Typically, yes. People use it to do benchmarking or cooldowns. I’m not sure if people outside of Roblox use it for cooldowns however.
Ok this is my last question what does os.clock return?
It returns the CPU Time used by the application [Lua] (in seconds).