Measuring execution time of a function inside linux kernel

后端 未结 3 1265
我寻月下人不归
我寻月下人不归 2020-12-24 06:50

I am using Linux Security Module hooks to add some custom functionality to recv() system call. I want to measure the overhead of this functionality as compared to the pristi

3条回答
  •  醉话见心
    2020-12-24 07:20

    I'm not sure you will obtain the result you want but we use the follwing code to have microseconds.

    double Microsecs()
    {
       static struct timeval _t;  
       static struct timezone tz;  
       gettimeofday(&_t, &tz);  
       return   (double)_t.tv_sec + (double)_t.tv_usec/(1000*1000);
    }
    

    Than you call it before and after the call you want and see how many time it.
    We've been using this method to evaluate IO time monitoring read/write/seek operation in order to oprimize performance and we're having good results.

    HTH.

提交回复
热议问题