Is one ms of delay that bad for this function?

I am not too into profiling, but I believe it might be a good thing to keep track of nevertheless.

.6391544 START
.6392865 END

This is the amount of time between the start and end of :quickplay().


if run_service:IsClient() then
	script.events.call_tween.OnClientEvent:Connect(function(instance, tween_info: {any}, properties)
		if not instance or not tween_info or not properties then
			return
		end
		
		local tween_info = TweenInfo.new(tween_info.time, tween_info.easingstyle, tween_info.easingdirection, tween_info.repeatcount, tween_info.reverses, tween_info.delaytime)

		module.quickplay(instance, tween_info, properties)
	end)
end

function module.quickplay(instance: Instance, tween_info: TweenInfo, properties: {}): Tween
	if run_service:IsClient() then
		local tween = tween_service:Create(instance, tween_info, properties)
		
		tween:Play()
	else
		script.events.call_tween:FireAllClients(instance, {time = tween_info.Time, easingstyle = tween_info.EasingStyle, easingdirection = tween_info.EasingDirection, reverses = tween_info.Reverses, delaytime = tween_info.DelayTime, repeatcount = tween_info.RepeatCount}, properties)
	end
end

Is that an okay time for this code? This is assuming the remote event is not being called and is just being turned into a tween. By that, i mean this profiling is done with the function being run on pure clientside.

Also if anyone is wondering why I don’t just develop a tween in this scenario, I plan on adding more features and customizability to my module in the future, so it’s best for consistancy.

Actually, the delay is realistically around 50 ms at best, at worst is 400 ms. It can be worse if servers are deteriorating. You can add the artificial lag by setting it in Studio by going to Studio Settings > Network > Incoming Replication Lag.

Play around with that to see how much it impacts the system through lag.

2 Likes

I apologize. I meant this function is being ran clientside.

1 Like

1 ms is fully negligible. Not even a full concern for timing in general. It only starts becoming noticeable as it reaches tens or hundreds, if that’s the answer you want.

1 Like

Roblox caps their FPS at 60, so you get ~16 ms per frame. Just keep it under that and you shouldn’t see any issues with frame drops.

It’s very strange for the tween to take an entire 1 ms to run the function, but I guess it depends on your PC and how fast your CPU is.

the point of the function is to make the tween support server/client side replication with less lag, and also a few other planned things in the future

Oh, correction on what you measured.

The duration on this is 100 us (micro seconds, or 10^-6) not 1 ms. This is a much more normal time.

It’s generally not recommended to tween on the server side. What most people do is the following architecture.
Action: Tween an Object → Server :FireAllClient and pass the tween data → Clients move the part with TweenService

1 Like

that’s exactly what this module does

1 Like