Do something for 10 sec

How to continue doing something for lets say 10 seconds and then break. Do I need to use coroutines? And how?
eg:

for (int i=0; i<10000; i++) 
{
			Debug.Log(i);
			// break after 10 sec
}

public float tenSec = 10;
public bool timerRunning = true;
int i;

	void Update(){
	if(timerRunning){
		tenSec -= Time.smoothDeltaTime;
			if(tenSec >= 0){
				Debug.Log(i++);
			}else{
				Debug.Log("Done");
				timerRunning = false;
			}
		}
	}

or with Corutine :

void Start () 
	{
		StartCoroutine(StartCounter ());
	}
	
	private IEnumerator StartCounter()
	{
		countDown = 10f;
		for (int i=0; i < 10000; i++) 
		{
			while (countDown >= 0)
			{
				Debug.Log(i++);
				countDown -= Time.smoothDeltaTime;
				yield return null;
			}
		}
	}

when i want to count , i use this code :

var Sec:**float**;

function Update()
{
   if(Sec <= 10)
   { Sec += 1*Time.deltaTime; print(Sec); }
}

it increase the Sec variable 1 unit in every second .