Compare commits

...

5 Commits

Author SHA1 Message Date
Benrob0329 75f23bb004 Fix another copy+paste error 2021-02-09 04:42:34 +00:00
Benrob0329 eb32bf2840 Fix copy+paste error 2021-02-09 04:42:12 +00:00
Benrob0329 a95743b0e1 Shrink calpi function 2021-02-09 04:41:48 +00:00
Benrob0329 b958af6424 Improve status messages, add initial mapgen benchmark (broken, do not use) 2017-12-12 14:47:13 -05:00
Benrob0329 1fa725cb36 Print the time 2017-12-11 22:34:43 -05:00
4 changed files with 44 additions and 22 deletions

View File

@ -1,20 +0,0 @@
local calpi = function()
local operator = '+'
local mypi = 0
for i=1, 10000000000, 2 do
if operator == '+' then
mypi = mypi + (4/i)
operator = '-'
elseif operator == '-' then
mypi = mypi - (4/i)
operator = '+'
end
end
print(mypi)
end
start = os.clock()
calpi()
stop = os.clock()
return (stop - start)

16
calpi.lua Normal file
View File

@ -0,0 +1,16 @@
local unpack = unpack or table.unpack
local function calpi()
local op = true
local operator = "+"
local mypi = 0
for i=1, 10000000000, 2 do
mypi, op = (op and mypi+(4/i) or mypi-(4/i)), (not op and true or false)
end
end
start = os.clock()
calpi()
stop = os.clock()
return (stop - start)

View File

@ -1,12 +1,23 @@
local modpath = minetest.get_modpath("benchmark")
local printall = function(string)
minetest.chat_send_all(string)
print(string)
end
minetest.register_chatcommand("benchmark", {
params = "",
description = "Benchmark the server (will stop everything for ~15 seconds)",
func = function(name, param)
if minetest.check_player_privs(name, {server=true}) then
local benchmark = dofile(modpath .. "/benchmark.lua")
minetest.chat_send_all(benchmark)
printall("Starting Pi Benchmark")
local calpi = dofile(modpath .. "/calpi.lua")
printall("Pi took " .. calpi .. " seconds.")
--printall("Starting Mapgen Benchmark")
--local mapgen = dofile(modpath .. "/mapgen.lua")
--printall("Mapgen took: " .. mapgen .. "seconds.")
return true, "Done."
else return false, "Operation not permitted"
end

15
mapgen.lua Normal file
View File

@ -0,0 +1,15 @@
local sleep = function(time)
while os.time() ~= (start+time) do end
end
local start = os.time()
minetest.emerge_area({x=30000, y=0, z=30000}, {x=29990, y=0, z=29990})
while (not minetest.get_node_or_nil({x=29990, 0, 29990})) do
sleep(1)
end
stop = os.time()
return (stop - start)