Performance of generating 5 242 880 numbers #1994
Replies: 3 comments
-
I managed to get a primitive local function test_array2(edge_size)
print("Generating 2D perlin noise array...")
local time_start = os.clock()
local cell_size = 5
local x = array.new({edge_size, edge_size, cell_size}, 1)
local y = array.new({edge_size, edge_size, cell_size}, 2)
local n = array.noise(x, y)
local time_end = os.clock()
print("Generated " .. #n .. " numbers, took " .. (time_end - time_start) .. " seconds")
end This is not 100% the same as the first version (missing the 0.25, 0.5, 0.75 offsets), more like a prototype ndarray implementation. It takes 0.26 seconds, according to perf mainly because it has to malloc 3 times, instead of once. I copied the perlin algo from Is there a numpy-like library I can use with Luau? I can implement the methods more or less but I feel like I would duplicate work and my version would be sub standard. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/mihaly-sisak/luau_torch7 |
Beta Was this translation helpful? Give feedback.
-
I polished it up, added back a lot of features that first did not work |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody!
I plan on implementing add-on support for my pet project, and so far Luau looks like the most battle tested solution! I love the sandboxing and the type checking features!
One of my use-cases would be world generation. I threw together an example script to see what I can do.
Please be gentle, this is my first lua code ever. I plan to sample a 2d perlin noise, then filter the results and generate a world based on that.
My problem is that this takes 0.6 seconds to run. (The same thing is cpp takes 0.19) I tried profiling:

Sadly this gives me no pointer where the bottleneck is. Is this lua code sane? I find it difficult to find resources for lua, is there some golden tutorial for luau, on how to write performant lua code?
Beta Was this translation helpful? Give feedback.
All reactions