summaryrefslogtreecommitdiffstats
path: root/grub-core/lib/libgcrypt/cipher/test-getrusage.c
blob: 479eaab8dafe2fbc1fca3580a66687191bae4650 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>

int
main (int argc, char **argv)
{
  struct rusage buf;

  if (argc > 1)
    {
      system (argv[1]);

      if (getrusage (RUSAGE_CHILDREN, &buf ))
        {
          perror ("getrusage");
          return 1;
        }
    }
  else
    {
      if (getrusage (RUSAGE_SELF, &buf ))
        {
          perror ("getrusage");
          return 1;
        }
    }

  printf ("ru_utime   = %ld.%06ld\n",
          buf.ru_utime.tv_sec, buf.ru_utime.tv_usec); 
  printf ("ru_stime   = %ld.%06ld\n",
          buf.ru_stime.tv_sec, buf.ru_stime.tv_usec);
  printf ("ru_maxrss  = %ld\n", buf.ru_maxrss   );
  printf ("ru_ixrss   = %ld\n", buf.ru_ixrss    );
  printf ("ru_idrss   = %ld\n", buf.ru_idrss    );
  printf ("ru_isrss   = %ld\n", buf.ru_isrss    );
  printf ("ru_minflt  = %ld\n", buf.ru_minflt   );
  printf ("ru_majflt  = %ld\n", buf.ru_majflt   );
  printf ("ru_nswap   = %ld\n", buf.ru_nswap    );
  printf ("ru_inblock = %ld\n", buf.ru_inblock  );
  printf ("ru_oublock = %ld\n", buf.ru_oublock  );
  printf ("ru_msgsnd  = %ld\n", buf.ru_msgsnd   );
  printf ("ru_msgrcv  = %ld\n", buf.ru_msgrcv   );
  printf ("ru_nsignals= %ld\n", buf.ru_nsignals );
  printf ("ru_nvcsw   = %ld\n", buf.ru_nvcsw    );
  printf ("ru_nivcsw  = %ld\n", buf.ru_nivcsw   );

  fprintf (stderr, "ru_utime   ru_stime   ru_minflt  ru_nccsw  ru_nivcsw\n");
  fprintf (stderr, "%ld.%06ld  %ld.%06ld  %5ld       %5ld      %5ld\n");


  return 0;
}


/* Codesnippet for debugging in random.c. */
#if 0
static void
collect_rusage_stats (struct rusage *rb)
{
  static int idx;
  static struct rusage buf[100];
  
  if (!rb)
    {
      int i;

      fprintf (stderr, "ru_utime   ru_stime   ru_minflt  ru_nvcsw  ru_nivcsw\n");
      for (i=0; i < idx; i++)
        fprintf (stderr, "%ld.%06ld   %ld.%06ld %5ld       %5ld      %5ld\n",
                 buf[i].ru_utime.tv_sec, buf[i].ru_utime.tv_usec, 
                 buf[i].ru_stime.tv_sec, buf[i].ru_stime.tv_usec, 
                 buf[i].ru_minflt, 
                 buf[i].ru_nvcsw,
                 buf[i].ru_nivcsw);
    }      
  else if (idx < DIM(buf))
    {
      buf[idx++] = *rb;
    }
}
#endif
/*
 void
 _gcry_random_dump_stats()
 {
@@ -233,8 +261,11 @@
                  rndstats.naddbytes, rndstats.addbytes,
        rndstats.mixkey, rndstats.ngetbytes1, rndstats.getbytes1,
                    rndstats.ngetbytes2, rndstats.getbytes2 );
+
+    collect_rusage_stats (NULL);
 }

========

     getrusage (RUSAGE_SELF, &buf );
+    collect_rusage_stats (&buf);
     add_randomness( &buf, sizeof buf, 1 );
     memset( &buf, 0, sizeof buf );
   }
 
*/