unbench, untests templates

This commit is contained in:
BlackMATov
2024-11-10 20:09:15 +07:00
parent 05bc158041
commit 25bc97bba3
4 changed files with 51 additions and 0 deletions

4
evolved.lua Normal file
View File

@@ -0,0 +1,4 @@
---@class evolved
local evolved = {}
return evolved

1
example.lua Normal file
View File

@@ -0,0 +1 @@
local evolved = require 'evolved'

23
unbench.lua Normal file
View 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
View 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