Which of these 2 script snips is better performance in larger conditionals

Which ones best?

local b = "a";
if b == "a" then
elseif b == "c" then
elseif b == "d" then
end;

local a = "";
local _0 = a;
repeat
    if _0 == "hello" then
        break;
    end;
    if _0 == "time" then
        break;
    end;
    if _0 == "" then
        break;
    end;
until true;

Looking at performance and also considering each has 100+ conditional statements.

I converted this from typescript and I wanted to know performance when converted to lua.

To me it seems like the first one would be slightly better but who knows.

The first one looks like it is better. Just use a check with tick() and compare the 2 times.

Well it depends on what you want to achieve.

If your goal is to create a one time check for a value, use the first script. If you want to constantly check for a value, the second one is ideal. However, the repeat until true will infinitely loop (Yields the script) until the a condition is met. You may want to throw it into a separate thread if you don’t want it to yield, but still check in the background.

As for performance, the difference is minimal. A computer is not to be taken lightly, and the code you’re running is not heavy in any sort of way. It really just depends on what goal you’re trying to achieve.

Instead of the repeat loop, I’d probably fire a BindableEvent with a parameter and execute the if check within that event. That way, you won’t have to yield any threads and always have to loop. If ever you do need a thread to yield, you could use BindableEvent:Wait(), which stops the thread until the event is fired. Since it’s an internal function, it’s just slightly faster than coding it yourself.

Again, the performance is barely impacted in both scripts, it really depends on what you’re trying to achieve.