Advertisement
Guest User

[TEST] packet: change call of synchronize_net to call_rcu

a guest
Sep 4th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <arpa/inet.h>
  7. #include <net/ethernet.h>
  8. #include <errno.h>
  9. #include <time.h>
  10.  
  11. #define SOCK_LIMIT1 5000
  12. #define SOCK_LIMIT2 10000
  13. /* Total number of sockets is (SOCK_LIMIT1 * SOCK_LIMIT2) */
  14.  
  15. int main (int argc, char **argv)
  16. {
  17.     int i, j, sd;
  18.     double secs = 0.0;
  19.  
  20.     for(i = 0; i < SOCK_LIMIT1; ++i)
  21.         for(j = 0; j < SOCK_LIMIT2; ++j) {
  22.             /* Submit request for a raw socket descriptor */
  23.             if ((sd = socket (PF_PACKET, SOCK_RAW, htons (ETH_P_ALL))) < 0) {
  24.                 perror ("socket() failed ");
  25.                 exit (EXIT_FAILURE);
  26.             }
  27.  
  28.             clock_t start = clock();
  29.             /* Close socket descriptor */
  30.             close (sd);
  31.             secs += (double)(clock() - start) / (double) CLOCKS_PER_SEC;
  32.         }
  33.  
  34.     printf("Sock closing time (secs): %.2f\n", secs);
  35.     return (EXIT_SUCCESS);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement