Take timestamp when frame come in

I want to measure time from frame come in until I get the buffer.
What api to use? how can I get the time?

Have reference to below topic.