How is Total Active Time Measured.

I would like to know the code behind how it measure this stat. Like what does it consider active and not active.