Tizen 2.0 Release
[external/bootchart.git] / bootchart.h
1 /*
2  * bootchart.h
3  *
4  * Copyright (c) 2009 Intel Coproration
5  * Authors:
6  *   Auke Kok <auke-jan.h.kok@intel.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; version 2
11  * of the License.
12  */
13
14
15 #define VERSION "0.1"
16
17 #define MAXCPUS         8
18 #define MAXPIDS     65535
19 #define MAXSAMPLES   8192
20
21
22 struct block_stat_struct {
23         /* /proc/vmstat pgpgin & pgpgout */
24         int bi;
25         int bo;
26 };
27
28 struct cpu_stat_sample_struct {
29         /* /proc/schedstat fields 10 & 11 (after name) */
30         double runtime;
31         double waittime;
32 };
33
34 struct cpu_stat_struct {
35         /* per cpu array */
36         struct cpu_stat_sample_struct sample[MAXSAMPLES];
37 };
38
39 /* per process, per sample data we will log */
40 struct ps_sched_struct {
41         /* /proc/<n>/schedstat fields 1 & 2 */
42         double runtime;
43         double waittime;
44         int pss;
45 };
46
47 /* process info */
48 struct ps_struct {
49         struct ps_struct *children;
50         struct ps_struct *next;
51
52         /* must match - otherwise it's a new process with same PID */
53         char name[16];
54         int pid;
55         int ppid;
56
57         /* cache fd's */
58         int sched;
59         int schedstat;
60         FILE *smaps;
61
62         /* index to first/last seen timestamps */
63         int first;
64         int last;
65
66         /* records actual start time, may be way before bootchart runs */
67         double starttime;
68
69         /* record human readable total cpu time */
70         double total;
71
72         /* largest PSS size found */
73         int pss_max;
74
75         /* for drawing connection lines later */
76         double pos_x;
77         double pos_y;
78
79         struct ps_sched_struct sample[MAXSAMPLES];
80 };
81
82
83 extern double graph_start;
84 extern double log_start;
85 extern double sampletime[];
86 extern struct ps_struct *ps[]; /* ll */
87 extern struct block_stat_struct blockstat[];
88 extern struct cpu_stat_struct cpustat[];
89 extern int pscount;
90 extern int relative;
91 extern int filter;
92 extern int pss;
93 extern int initcall;
94 extern int samples;
95 extern int cpus;
96 extern int len;
97 extern int hz;
98 extern int scale_x;
99 extern int scale_y;
100 extern int overrun;
101 extern double interval;
102
103 extern char output_path[PATH_MAX];
104 extern char init_path[PATH_MAX];
105
106 extern FILE *of;
107
108 extern double gettime_ns(void);
109 extern void log_uptime(void);
110 extern void log_sample(int sample);
111
112 extern void svg_do(void);
113