os and io Libraries
Access system time, environment variables, file system, and stdin/stdout.
The os Module Overview
The os module provides access to operating system features: time, date, environment variables, process control, and file system operations.
os.time and os.clock
os.time() returns the current time as a Unix timestamp. os.clock() returns CPU time used by the program — useful for benchmarking.
local t0 = os.clock()
for i = 1, 1e6 do end
print(("%.4f sec CPU"):format(os.clock() - t0))All lessons in this course
- math Library Functions
- table Library Functions
- os and io Libraries
- The debug Library