Novak Djokovic beat Richard Gasquet in three sets as he warmed up for Sunday's ATP World Tour Finals semi-final with a demanding workout.