0Pricing
Lua Academy · Lesson

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

  1. math Library Functions
  2. table Library Functions
  3. os and io Libraries
  4. The debug Library
← Back to Lua Academy