Monitor Signal Duration on Arduino Mega

I am a beginner so some of my statements may sound foolish. XD

I want to use my Arduino to monitor the duration of a signal from my sensor.
I have both analog and digital signals from 2 different outputs of the sensor.
I want to know how long the signal lasts and use the value of the duration for further computation.
I could use the analog, the digital or both for this purpose.

I dont know how to go about it.
Any help please.

Thank you.

Hi, here is my idea.

unsigned long duration;
unsigned long startTime;
byte trigger = 0;

void loop() 
{
  if( digitalRead(yourPin) == HIGH && trigger == 0 )
  {
    startTime = micros();
    trigger = 1;
  }
  else if( digitalRead(yourPin) == LOW && trigger == 1 )
  {
    duration = micros() - startTime; //result in microseconds
    trigger = 0;
  }
}

Byork:
Hi, here is my idea.

unsigned long duration;

unsigned long startTime;
byte trigger = 0;

void loop()
{
  if( digitalRead(yourPin) == HIGH && trigger == 0 )
  {
    startTime = micros();
    trigger = 1;
  }
  else if( digitalRead(yourPin) == LOW && trigger == 1 )
  {
    duration = micros() - startTime; //result in microseconds
    trigger = 0;
  }
}

Thanks for your response. Please could you add some explanation of the codes.
Besides I'm also considering the possibility of using an interrupt. Could you also give me some help in that regard.

Another problem is that this signal may tend to fluctuate a bit but I want the time to run uninterrupted till the signal ends.