mirror of
https://github.com/BlackMATov/evolved.lua.git
synced 2025-12-12 19:16:14 +07:00
unbench, untests templates
This commit is contained in:
4
evolved.lua
Normal file
4
evolved.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
---@class evolved
|
||||
local evolved = {}
|
||||
|
||||
return evolved
|
||||
1
example.lua
Normal file
1
example.lua
Normal file
@@ -0,0 +1 @@
|
||||
local evolved = require 'evolved'
|
||||
23
unbench.lua
Normal file
23
unbench.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local evolved = require 'evolved'
|
||||
|
||||
---@param name string
|
||||
---@param func fun(...):...
|
||||
---@param ... any
|
||||
local function describe(name, func, ...)
|
||||
collectgarbage('stop')
|
||||
|
||||
print(string.format('- %s ...', name))
|
||||
|
||||
local start_s = os.clock()
|
||||
local start_kb = collectgarbage('count')
|
||||
|
||||
local success = pcall(func, ...)
|
||||
|
||||
local finish_s = os.clock() - start_s
|
||||
local finish_kb = collectgarbage('count') - start_kb
|
||||
|
||||
print(string.format(' %s | ms: %f | kb: %f',
|
||||
success and 'OK' or 'FAILED', finish_s * 1000, finish_kb))
|
||||
|
||||
collectgarbage('restart')
|
||||
end
|
||||
23
untests.lua
Normal file
23
untests.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local evolved = require 'evolved'
|
||||
|
||||
---@param name string
|
||||
---@param func fun(...):...
|
||||
---@param ... any
|
||||
local function describe(name, func, ...)
|
||||
collectgarbage('stop')
|
||||
|
||||
print(string.format('- %s ...', name))
|
||||
|
||||
local start_s = os.clock()
|
||||
local start_kb = collectgarbage('count')
|
||||
|
||||
local success = pcall(func, ...)
|
||||
|
||||
local finish_s = os.clock() - start_s
|
||||
local finish_kb = collectgarbage('count') - start_kb
|
||||
|
||||
print(string.format(' %s | ms: %f | kb: %f',
|
||||
success and 'OK' or 'FAILED', finish_s * 1000, finish_kb))
|
||||
|
||||
collectgarbage('restart')
|
||||
end
|
||||
Reference in New Issue
Block a user