我正在尝试制作一个基于链表的内核模块,我想测量1000个项目插入列表的执行时间。
我应该使用什么头文件和什么函数来测量开始时间和结束时间?
// 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
我提供了一个链接到我的一个内核模块,在那里我解决了同样的任务。
这里是GitHub项目链接,您可以查看方法print_perf_data
,以了解我如何收集性能数据并打印它们以计算经过的时间。
致意。