MPU6050 Gyro value going back to initial value irrespective of Angle

How to calculate drift ?

is following implementation correct ?

void setup(){
   
   int totalVal = 0;
    for (int i =0; i < 1000 ; i++){
       readGyroX();
       totalVal = totalVal + rotX;
}//end of for

  offsetVal = totalVal/1000;

}//end of setup