mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2026-09-14 11:06:16 +05:00
Ну-ка
This commit is contained in:
parent
8e66877c69
commit
10abe1ad4b
@ -86,48 +86,52 @@ end
|
||||
|
||||
------------------------------------------------- Playground -----------------------------------------------------------------
|
||||
|
||||
-- local sampleTable = {
|
||||
-- "one",
|
||||
-- "two",
|
||||
-- "three",
|
||||
-- [9] = 9,
|
||||
-- [10] = "ten",
|
||||
-- [11] = "eleven",
|
||||
-- ["test"] = "sucess",
|
||||
-- ["tableTest"] = {
|
||||
-- ["tableInTable"] = {
|
||||
-- [12] = "blah-blah",
|
||||
-- ["hello"] = "world",
|
||||
-- },
|
||||
-- "cyka",
|
||||
-- "blyad",
|
||||
-- },
|
||||
-- ["nilTest"] = nil,
|
||||
-- ["booleanTest"] = true,
|
||||
-- }
|
||||
local sampleTable = {
|
||||
"one",
|
||||
"two",
|
||||
"three",
|
||||
[9] = 9,
|
||||
[10] = "ten",
|
||||
[11] = "eleven",
|
||||
["test"] = "sucess",
|
||||
["tableTest"] = {
|
||||
["tableInTable"] = {
|
||||
[12] = "blah-blah",
|
||||
["hello"] = "world",
|
||||
},
|
||||
"cyka",
|
||||
"blyad",
|
||||
},
|
||||
["nilTest"] = nil,
|
||||
["booleanTest"] = true,
|
||||
}
|
||||
|
||||
-- local function fillTable()
|
||||
-- for i = 1, 1000 do
|
||||
-- table.insert(sampleTable, math.random(1, 100000))
|
||||
-- end
|
||||
-- end
|
||||
local function fillTable(count)
|
||||
print("Filling table with " .. count .. " random values...")
|
||||
for i = 1, count do
|
||||
table.insert(sampleTable, math.random(1, 100000))
|
||||
end
|
||||
end
|
||||
|
||||
-- local function executeAndPrintExecutionTime(method, ...)
|
||||
-- local oldTime = os.clock()
|
||||
-- method(...)
|
||||
-- print(os.clock() - oldTime)
|
||||
-- end
|
||||
local function executeAndPrintExecutionTime(method, ...)
|
||||
local oldTime = os.clock()
|
||||
method(...)
|
||||
print("Execution time: " .. os.clock() - oldTime .. " seconds")
|
||||
end
|
||||
|
||||
-- local function compareAlgorhytms()
|
||||
-- local oldSerialization = require("openOSSerialization")
|
||||
-- print("Old:")
|
||||
-- executeAndPrintExecutionTime(oldSerialization.serialize, sampleTable)
|
||||
-- print("New:")
|
||||
-- executeAndPrintExecutionTime(serialization.serialize, sampleTable)
|
||||
-- end
|
||||
local function compareAlgorithms()
|
||||
print(" ")
|
||||
fillTable(10000)
|
||||
print(" ")
|
||||
local oldSerialization = require("openOSSerialization")
|
||||
print("Old:")
|
||||
executeAndPrintExecutionTime(oldSerialization.serialize, sampleTable)
|
||||
print("New:")
|
||||
executeAndPrintExecutionTime(serialization.serialize, sampleTable)
|
||||
print(" ")
|
||||
end
|
||||
|
||||
-- fillTable()
|
||||
-- compareAlgorhytms()
|
||||
compareAlgorithms()
|
||||
|
||||
----------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user