Updated stopwatch to show microsecond precision, works on linux

This commit is contained in:
Matthew Ellison
2019-02-06 02:00:24 -05:00
parent c1149d09a4
commit f9cce574cb

View File

@@ -1,7 +1,7 @@
--luaClasses/Stopwatch.lua --luaClasses/Stopwatch.lua
--Matthew Ellison --Matthew Ellison
-- Created: 2-1-19 -- Created: 02-01-19
--Modified: 2-1-19 --Modified: 02-06-19
--This is a simple class to be used to time runtimes of various things within programs --This is a simple class to be used to time runtimes of various things within programs
Stopwatch = { Stopwatch = {
@@ -34,8 +34,12 @@ function Stopwatch:getTime()
return (self.stopTime - self.startTime) return (self.stopTime - self.startTime)
end end
function Stopwatch:getMicroseconds()
return math.floor(self:getTime() * 1000000)
end
function Stopwatch:getMilliseconds() function Stopwatch:getMilliseconds()
return math.floor((self:getTime() * 1000)) return (self:getTime() * 1000)
end end
function Stopwatch:getSeconds() function Stopwatch:getSeconds()