Measure PWM Duty Cycle on a Specific PIN (Arduino Mega )

Thanks for your responses.

I have found few solutions from the google but its not clear of how to calculate the duty cycle on a specific pin which supports PWM signal.

BUT I might need some guidance from the below example, of to calculate the duty cycle ?

http://www.benripley.com/diy/arduino/three-ways-to-read-a-pwm-signal-with-arduino/

#include <PinChangeInt.h>

#define MY_PIN 5 // we could choose any pin

volatile int pwm_value = 0;
volatile int prev_time = 0;
uint8_t latest_interrupted_pin;

void rising()
{
 latest_interrupted_pin=PCintPort::arduinoPin;
 PCintPort::attachInterrupt(latest_interrupted_pin, &falling, FALLING);
 prev_time = micros();
}

void falling() {
 latest_interrupted_pin=PCintPort::arduinoPin;
 PCintPort::attachInterrupt(latest_interrupted_pin, &rising, RISING);
 pwm_value = micros()-prev_time;
 Serial.println(state);
}

void setup() {
 pinMode(MY_PIN, INPUT); digitalWrite(MY_PIN, HIGH);
 Serial.begin(115200);
 PCintPort::attachInterrupt(MY_PIN, &rising, RISING);
}

void loop() { }

Regards
Ravi