简体   繁体   English

内核模块时间测量

[英]Kernel Module Time measuring

I am trying to make a kernel module based on linked list and I want to measure the execution time of insertion of 1000 items into the list.我正在尝试基于链表制作内核模块,我想测量将 1000 个项目插入列表的执行时间。

What header file and what function should I use to measure the starting time and the end time?我应该使用什么头文件和什么函数来测量开始时间和结束时间?

    // start clock here
    for(i = 0; i < 1000; i++)
    { 
         struct my_node* new = kmalloc(sizeof(struct my_node), GFP_KERNEL);
         new->data = i;
         list_add(&new->entry, &my_list);
    }
    // end clock here
    // print out the execution time in seconds here

I provide you a link to a kernel module of mine where I solved the same task.我为您提供了一个指向我的内核模块的链接,我在其中解决了相同的任务。

Here is the GitHub project link where you could look at the method print_perf_data to see how I collect performance data and print them calculating the elapsed time.这是GitHub 项目链接,您可以在其中查看方法print_perf_data以了解我如何收集性能数据并打印它们以计算经过的时间。

Regards.问候。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM