minetest-mods / moreblocks

More Blocks
https://content.minetest.net/packages/Calinou/moreblocks/
zlib License
45 stars 67 forks source link

Make wool sawable (testing results) #71

Closed Fixer-007 closed 7 years ago

Fixer-007 commented 7 years ago

That's response to Calinou's comment here: https://github.com/minetest-mods/moreblocks/issues/20#issuecomment-130081465 I did testing of moreblocks load times without wool and with wool, here's how I did it: init.lua:

--[[
=====================================================================
** More Blocks **
By Calinou, with the help of ShadowNinja and VanessaE.

Copyright (c) 2011-2017 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
=====================================================================
--]]

local clock = os.clock
local t1 = clock()

moreblocks = {}

local S
if minetest.get_modpath("intllib") then
    S = intllib.Getter()
else
    S = function(s) return s end
end
moreblocks.intllib = S

local modpath = minetest.get_modpath("moreblocks")

dofile(modpath .. "/config.lua")
dofile(modpath .. "/circular_saw.lua")
dofile(modpath .. "/stairsplus/init.lua")
dofile(modpath .. "/nodes.lua")
dofile(modpath .. "/redefinitions.lua")
dofile(modpath .. "/crafting.lua")
dofile(modpath .. "/aliases.lua")

if minetest.setting_getbool("log_mods") then
    minetest.log("action", S("[moreblocks] loaded."))
end

local dt = clock() - t1
minetest.log("action", dt)

and registrations.lua (thanks for Vanessa code in PRs)

--[[
More Blocks: registrations

Copyright (c) 2011-2017 Hugo Locurcio and contributors.
Licensed under the zlib license. See LICENSE.md for more information.
--]]

local default_nodes = { -- Default stairs/slabs/panels/microblocks:
    "stone",
    "cobble",
    "mossycobble",
    "brick",
    "sandstone",
    "steelblock",
    "goldblock",
    "copperblock",
    "bronzeblock",
    "diamondblock",
    "desert_stone",
    "desert_cobble",
    "meselamp",
    "glass",
    "tree",
    "wood",
    "jungletree",
    "junglewood",
    "pine_tree",
    "pine_wood",
    "acacia_tree",
    "acacia_wood",
    "aspen_tree",
    "aspen_wood",
    "obsidian",
    "obsidian_glass",
    "stonebrick",
    "desert_stonebrick",
    "sandstonebrick",
    "obsidianbrick",
    "wool:black",
    "wool:blue",
    "wool:brown",
    "wool:cyan",
    "wool:dark_green",
    "wool:dark_grey",
    "wool:green",
    "wool:grey",
    "wool:magenta",
    "wool:orange",
    "wool:pink",
    "wool:red",
    "wool:violet",
    "wool:white",
    "wool:yellow",
}

for _, name in pairs(default_nodes) do
    local nodename = "default:".. name
    if string.find(name, ":") then
        nodename = name
    end
    local ndef = minetest.registered_nodes[nodename]
    if ndef then
        local drop
        if type(ndef.drop) == "string" then
            drop = ndef.drop:sub(9)
        end

        local tiles = ndef.tiles
        if #ndef.tiles > 1 and ndef.drawtype:find("glass") then
            tiles = { ndef.tiles[1] }
        end

        stairsplus:register_all("moreblocks", name, nodename, {
            description = ndef.description,
            drop = drop,
            groups = ndef.groups,
            sounds = ndef.sounds,
            tiles = tiles,
            sunlight_propagates = true,
            light_source = ndef.light_source
        })
    end
end 

Here are results! default

Mod loading time has increased from 0,258 to 0,326 seconds on avg (20 tests with each), or increase by 0,068 sec (+26%)

Therefore I want to propose to make wools sawable, since load times are tiny and not affected much. Tested on core i3 3.3GHz/5400rpm hdd