Scripting Helpers is winding down operations and is now read-only. More info→
Log in to vote
14

Can Roblox Handle 28800000 Raycasts per second? [closed]

Asked by 9 years ago

60 times a second, 800x600 raycasts. I was wondering if it can even handle 1/6 of what I'm going for?

Locked by YellowoTide, dyler3, and adark

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

2 answers

Log in to vote
7
Answered by
BlueTaslem 18071
9 years ago

No. Let's say you have a full 2GHz processor to run your game (I don't think you get that much, but it would be hard to tell). Let's say 1 ROBLOX function call takes 1000 instructions (this is probably an okay approximation). That means you get around 2,000,000 function calls / second.

This is a really rough estimate, but you're asking for more than 10 times this much.

You might be able to manage a similar effect, whatever it is you're doing, by being very clever (and perhaps a little approximate).

Log in to vote
4
Answered by 9 years ago

You can test it out for yourself by figuring out how long it takes for a single instruction to execute. Of course, this will heavily be computer and place dependent, but it can give you a rough idea:

n=1000
ray = Ray.new(Vector3.new(0,990,0), Vector3.new(0, -999, 0))
start=tick()
for i = 1, n do
workspace:FindPartOnRay(ray)
end
duration = tick()-start --technically this includes the time it takes to run the for loop, but realistically you'd be doing much more complex calculations (ex to create the ray for each iteration), so this is really an underestimate
print(duration, 1/(duration/n)) --the second number will be # of calls per second


(Put the above in a script, or simply copy/paste it into the Command Bar. Make sure your Output window is open.) For me, on a blank place (with a baseplate), this prints out numbers like 0.044166326522827 22641.683805946

In other words, Roblox on my computer can calculate about 22k raycasts per second, and that's in a practically empty place, and only if it's doing nothing else. I imagine a place with plenty of bricks could be significantly more computationally intensive.

With 20k raycasts, this could fill a screen of 200x100 pixels once per second, or 33x20 pixels 30x/sec

1
28800000 is wayyy out of the question then. Thanks! YellowoTide 1992 — 9y