Why are these functions so expensive ?

I want to inform other near by agents to the playerPos
but when i call followPlayer() in the Update i get 1-2 fps
I need help there must be other way to do it right ?

List NearBy() {

    foreach (GameObject zombie in zombies)
    {
      float distance=  Vector3.Distance(transform.position, zombie.transform.position);
        if (distance<=radius)
        {
            nearByZombie.Add(zombie);
        }

    }
    return (nearByZombie);
}

public void followPlayer()
{
    foreach (GameObject zombie in NearBy())
    {
        if (DistanceBetweenPlayerAndZombie())
        {
            Movement agentMovement = zombie.transform.GetComponent<Movement>();
            agentMovement.agent.SetDestination(player.position);
        }
      
        
    }

},I'm want to inform other near by agent to the playerPos

when i run SwampAi i get 2 fps is there is a better way of doing this ?

List NearBy() {

    foreach (GameObject zombie in zombies)
    {
      float distance=  Vector3.Distance(transform.position, zombie.transform.position);
        if (distance<=radius)
        {
            nearByZombie.Add(zombie);
        }

    }
    return (nearByZombie);
}

public void SwampAi()
{
    foreach (GameObject zombie in NearBy())
    {
        if (DistanceBetweenPlayerAndZombie())
        {
            Movement agentMovement = zombie.transform.GetComponent<Movement>();
            agentMovement.agent.SetDestination(player.position);
        }
      
        
    }

}

First of all, I don’t believe all your zombies need to be notified each frame of the position of the player. You can “dispatch” this task on multiple frames.

Then, calling GetComponent and Vector3.Distance is pretty “heavy”, especially when called multiple times each frame. If you have dozens of zombies, I understand why you are facing FPS drops.

Here is a suggestion, based on the (few) information you have provided.

public GameObject[] zombies;

private Movement[] zombiesMovement;

public void SwampAi()
 {
     int start = Time.frameCount % 2 == 0 ? 0 : zombies.Length / 2 ;
     int end   = Time.frameCount % 2 == 0 ? zombies.Length / 2 : zombies.Length ;

     for( int i = start ; i < end ; ++i )
     {
         if ( (transform.position - zombie.transform.position).sqrMagnitude <= radius * radius && DistanceBetweenPlayerAndZombie() )
         {
             if( zombiesMovement *== null )*

zombiesMovement = zombies*.GetComponent();*
zombiesMovement*.agent.SetDestination(player.position);*
}
}
}