mirror of
https://github.com/TangentFoxy/lume.git
synced 2025-07-28 11:02:20 +00:00
Added lume.time(), incremented version revision
This commit is contained in:
@@ -149,6 +149,13 @@ local f = lume.fn(print, "Hello")
|
|||||||
f() -- Prints "Hello"
|
f() -- Prints "Hello"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### lume.time(fn, ...)
|
||||||
|
Inserts the arguments into function `fn` and calls it. Returns the time in
|
||||||
|
seconds the function `fn` took to execute followed by `fn`'s returned values.
|
||||||
|
```lua
|
||||||
|
lume.time(function(x) return x end, "hello") -- Returns 0, "hello"
|
||||||
|
```
|
||||||
|
|
||||||
### lume.serialize(x)
|
### lume.serialize(x)
|
||||||
Serializes the argument `x` into a string which can be loaded again using
|
Serializes the argument `x` into a string which can be loaded again using
|
||||||
`lume.deserialize()`. Only booleans, numbers, tables and strings can be
|
`lume.deserialize()`. Only booleans, numbers, tables and strings can be
|
||||||
|
9
lume.lua
9
lume.lua
@@ -7,7 +7,7 @@
|
|||||||
-- under the terms of the MIT license. See LICENSE for details.
|
-- under the terms of the MIT license. See LICENSE for details.
|
||||||
--
|
--
|
||||||
|
|
||||||
local lume = { _version = "1.0.4" }
|
local lume = { _version = "1.0.5" }
|
||||||
|
|
||||||
|
|
||||||
function lume.clamp(x, min, max)
|
function lume.clamp(x, min, max)
|
||||||
@@ -178,6 +178,13 @@ function lume.fn(fn, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function lume.time(fn, ...)
|
||||||
|
local start = os.clock()
|
||||||
|
local rtn = {fn(...)}
|
||||||
|
return (os.clock() - start), unpack(rtn)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function lume.serialize(x)
|
function lume.serialize(x)
|
||||||
local f = { string = function(v) return string.format("%q", v) end,
|
local f = { string = function(v) return string.format("%q", v) end,
|
||||||
number = tostring, boolean = tostring }
|
number = tostring, boolean = tostring }
|
||||||
|
Reference in New Issue
Block a user