waitforseconds in update good for perfomance ?

hey at all,
i’m experimenting with waitforseconds in update(). In the manual is explained that this would greatly reduce the number of checks carried out.
So i changed my Script from :
void Update ()
{

				thisMiss1conf = Miss1confirmedScr.Miss1confirm;
		
				if(thisMiss1conf)
				{
						Einl_Sound_2.SetActive(true);
						thisRatPack.SetActive(true);
						Miss1Canvas.SetActive(false);
						BeendenButt.SetActive(false);
				}

				if(!jalthiPack1[0].activeSelf && !jalthiPack1[1].activeSelf && !jalthiPack1[2].activeSelf && !jalthiPack1[3].activeSelf &&
					!jalthiPack1[4].activeSelf &&thisMiss1conf &&  thisRatPack.activeSelf)
				{
						Miss1done = true;
						thisMissaccImg.SetActive(true);
				}
		}

to :

		void Start () 
		{
				Miss1confirmedScr = Einl1Obj.GetComponent<Einleitung_1>();
				thisRatPack.SetActive(false);
				Einl_Sound_1.SetActive(true);
				Einl_Sound_2.SetActive(false);
				StartCoroutine(xxx());
		}
	
		void Update () 
		{
				
				thisMiss1conf = Miss1confirmedScr.Miss1confirm;
				StartCoroutine("xxx");
				if(thisMiss1conf)
				{
						Einl_Sound_2.SetActive(true);
						thisRatPack.SetActive(true);
						Miss1Canvas.SetActive(false);
						BeendenButt.SetActive(false);
						StartCoroutine("xxx");
				}

				if(!jalthiPack1[0].activeSelf && !jalthiPack1[1].activeSelf && !jalthiPack1[2].activeSelf && !jalthiPack1[3].activeSelf &&
					!jalthiPack1[4].activeSelf &&thisMiss1conf &&  thisRatPack.activeSelf)
				{
						Miss1done = true;
						thisMissaccImg.SetActive(true);
						StartCoroutine("xxx");
				}
				StartCoroutine("xxx");
		}


		IEnumerator xxx()
		{
				yield  return new WaitForSeconds(0.1f);
		}

well, it works and i dont get any errors. What i would like to know if its really correct or nonsens. And if its really a benefit for perfomance although i cant “see” a big difference in fps.
But i think “if so” i have several more scripts in which the functions in Update() hasn’t to be calculated absolutely precise in every frame and could be also changed in this way.
And in summary it would make a difference for perfomance, wouldn’t it?
I’m very nosily about your opinion or tips and tricks

yours

Fade() is started inside Update() but ONLY if the “f” key is pressed. So, if the end user pressed the “f” key repeatedly, it would start a new instance of the Fade() coroutine per key press. Not a good practice!

Similarly, if you start your coroutine at the end of Update, a new instance of the coroutine would get started every single frame, very bad for performance, and it’s not intended behavior anyway.

However, you could have an if condition inside Update() to start the coroutine, e.g.

if(gameOver)
{
    StartCoroutine("xxx");
}

This would work, because in practice you can’t have gameOver = true occurring very frequently.

Instead of gameOver you can use any condition you like of course, but you should have in mind that the frequency that this boolean variable gets set to true is small.

You must also put the behavior that needs repeating every 0.1s inside the xxx coroutine, not inside Update. This is illustrated in both Fade() and DoCheck() in the examples.

In other words, if you just start the xxx coroutine, its WaitForSeconds(0.1f) will not affect at all in practice the rate at which Update() is called. To be more precise, the rate at which Update() gets called might be affected by other things in your code, but not by the WaitForSeconds(0.1f) itself.

puuh pretty confusing for a beginner ):

if i understand you wright the code should look like this (?) :

public bool nevertrue = true; // never become false

void Update () 
		{
				if(nevertrue)
				{
						StartCoroutine("xxx");
				}
		}


		IEnumerator xxx()
		{
				thisMiss1conf = Miss1confirmedScr.Miss1confirm;
				if(thisMiss1conf)
				{
						Einl_Sound_2.SetActive(true);
						thisRatPack.SetActive(true);
						Miss1Canvas.SetActive(false);
						BeendenButt.SetActive(false);
				}

				if(!jalthiPack1[0].activeSelf && !jalthiPack1[1].activeSelf && !jalthiPack1[2].activeSelf && !jalthiPack1[3].activeSelf  
                                && !jalthiPack1[4].activeSelf &&thisMiss1conf  &&  thisRatPack.activeSelf)

				{
						Miss1done = true;
						thisMissaccImg.SetActive(true);
				}
				
				yield  return new WaitForSeconds(0.1f);
       }  

i’ve tried that and all seems to work i’m just hoping that it will take effect even if its not noticeable.