It takes 30-40 minutes from Dongzhimen to Terminal 3 by airport express.
It takes about half an hour from the National Library to Dongzhimen.
The plane needs to board half an hour in advance.
Going through security check in the morning is also the peak period. How long it takes depends on whether you take an international flight or a domestic flight. The international flight is about 1.5 hours (take a small train to T3E), and the domestic flight is 1 hour.
This adds up to the time you need to move forward.