A wrapper library for CPU time measurement.
local cputime = require 'cputime' local utime, stime, err = cputime.get_process_cputime() if err ~= nil then -- error handling... end
See also example.
This package provides methods to measure (and dispense) the CPU time.
This library bridges to
getrusage() function of
sys/resource.h on UNIX system; on the other hand, this library wraps
GetThreadTimes() on Windows environment.
This function returns the measured CPU time of current process.
This function returns the measured CPU time of current thread. This function is only supported following OS:
- Linux (since 2.6.26)
The above methods returns values that accords the following order:
- utime (number or nil): user CPU time. This variable represents microseconds.
- stime (number or nil): system CPU time. This variable represents microseconds.
- err (string or nil): error response
When err is nil, other values are actual number value. On the other hand, when err is not nil, other values are nil.
The MIT License (MIT) Copyright © 2018 moznion, http://moznion.net/ <firstname.lastname@example.org> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.