LED timing using pulseIn

Hi, so i am trying to simply time the amount of time an led is on for here is what i have written using pulseIN:

int pin = 8;
int ledPin = 13;
unsigned long duration;
int x;
void setup() {
// put your setup code here, to run once:
pinMode(pin,INPUT);
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}

void loop() {
// put your main code here, to run repeatedly:
x = digitalRead(pin),
digitalWrite(ledPin, HIGH);
delay(1000);
duration = pulseIn(x,HIGH);
digitalWrite(ledPin, LOW);
delay(1000);
Serial.println(duration);
Serial.println(x);

}

I cnat get it to work so any help is greatly apreciated, thanks in advance

digitalWrite(ledPin, HIGH);
delay(1000);
duration = pulseIn(x,HIGH);
digitalWrite(ledPin, LOW);
delay(1000);

According to your understanding of pulseIn() - what is this supposed to do ?

As far as I was aware i could use pulseIn to time a pulse and then return that pulse time as an int that could be printed to serialM. But i gather i was mistaken

duration = pulseIn(x,HIGH);

This will wait for the pin to be LOW, then wait for the pin to go HIGH, and then count microseconds until the pin gots LOW again. In other words it measures the length of the next HIGH pulse.

What is causing pin 'x' to go HIGH and LOW? If it is the LED you are controlling, there will be no LOW/HIGH/LOW sequence to measure and pulseIn() will timeout after the default 1 second and return zero. Then a second after that your sketch will turn off the LED.

What’s x ? What does the pulseIn doc states about the first params?

x = digitalRead(pin),

So x will have a value of 0 or 1 depending on the state of the pin

duration = pulseIn(x,HIGH);

So here you don't even know what pin you're looking for a pulse on. Is it pin 0 or pin 1? What do you have connected to those pins? Your sketch uses Serial so the answer had better be nothing. In which case it is kind of ridiculous to look for a pulse there.

Are you trying to determine how long the LED is on? That's set by your code. You wrote delay(1000) so it will be 1000ms. There's no need to try to measure it. You already know it is 1000ms

Please describe what it is that you are trying to build / accomplish with this code.