简体   繁体   中英

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.

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.

Regards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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