Interrupt: Need to keep track of time spent in routine or ... ?

So what's wrong with a function like what I wrote?
Is every hardware device driven by a different line of code?