newbie need help to reduce FPS from the script !

I tried to use IEnumerator instead of FixedUpdate or Update but my FPS doesn’t improve much !

IEnumerator CheckUpdate(){
        yield return new WaitForSeconds (0.05f);
        if (healthBar.value <= 0|| checkRun == true) {
           
        } else {
            if (targets == null || targets.tag != ChaseEnemyTag)// if target death find another target
                targets = GameObject.FindGameObjectWithTag (ChaseEnemyTag);
            if (targets != null) {
                direction = targets.transform.position - this.transform.position;
                angle = Vector3.Angle (direction, this.transform.position);
                float distance = Vector3.Distance (targets.transform.position, this.transform.position);
                    if (targets.transform.GetChild (0).name == "front") {
                        if ( distance < 20 && angle < 90 ||  distance < 10) {
                            if (z == 1) {
                                checkRun = true;
                                runAway ();
                            } else {
                                direction.y = 0;
                                this.transform.rotation = Quaternion.Slerp (this.transform.rotation, Quaternion.LookRotation (direction), 0.1f);
                                m_Anim.SetBool ("IsIdle", false);
                                m_Anim.SetBool ("IsRunning", false);
                                if (direction.magnitude > m_AttackRange) {// if target isn't in attack range move to front of target
                                    m_Nav.Resume ();
                                    m_Nav.SetDestination (targets.transform.GetChild (0).position);
                                    m_Anim.SetBool ("IsWalking", true);
                                    m_Anim.SetBool ("IsAttacking", false);
                                } else {
                                    m_Nav.Stop ();
                                    this.transform.rotation = Quaternion.Slerp (this.transform.rotation, Quaternion.LookRotation (direction), 0.1f);
                                    m_Anim.SetBool ("IsWalking", false);
                                    m_Anim.SetBool ("IsAttacking", true);
                                }
                             }
                        } else {
                            targets = null;
                            Patrol ();
                        }
                    } else {
                        targets = null;
                        Patrol ();
                    }
                } else {
                    Patrol ();
                }
           
        }
        StartCoroutine (CheckUpdate ());
           
    }

Starting a new Coroutine has some overhead and making new WaitForSeconds has some overhead since it has to allocate memory which you make into garbage when the method is done. Instead you should have the Coroutine run as long as it is needed and reuse the WaitForSeconds.

You should avoid using Find in an Update loop although FindGameObjectWithTag is one of the fastest of the Find Methods it is still relatively slow.

Also the Animator calls by string is slower than if you use the Hash ID.

Here is a little example of how to avoid some of the garbage generated by the Coroutine.

    public Animator m_Anim;

    int isIdleHash = Animator.StringToHash("IsIdle");
    WaitForSeconds WaitForFiftyMilliseconds = new WaitForSeconds(0.05f);

    void Start()
    {
        StartCoroutine(SlowerUpdate());
    }

    IEnumerator SlowerUpdate()
    {
        while (true)
        {
            if (true /* Some meaningful condition*/)
            {
                m_Anim.SetBool(isIdleHash, false);
            }
            yield return WaitForFiftyMilliseconds;
        }
    }

Thank Pengocat my fps improve a lot !