Explorar el Código

[cmdline] Add "profstat" command to display profiling statistics

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown hace 10 años
padre
commit
7c44fd68f0
Se han modificado 5 ficheros con 132 adiciones y 0 borrados
  1. 3
    0
      src/config/config.c
  2. 1
    0
      src/config/general.h
  3. 70
    0
      src/hci/commands/profstat_cmd.c
  4. 14
    0
      src/include/usr/profstat.h
  5. 44
    0
      src/usr/profstat.c

+ 3
- 0
src/config/config.c Ver fichero

@@ -290,6 +290,9 @@ REQUIRE_OBJECT ( console_cmd );
290 290
 #ifdef IPSTAT_CMD
291 291
 REQUIRE_OBJECT ( ipstat_cmd );
292 292
 #endif
293
+#ifdef PROFSTAT_CMD
294
+REQUIRE_OBJECT ( profstat_cmd );
295
+#endif
293 296
 
294 297
 /*
295 298
  * Drag in miscellaneous objects

+ 1
- 0
src/config/general.h Ver fichero

@@ -149,6 +149,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
149 149
 //#define PING_CMD		/* Ping command */
150 150
 //#define CONSOLE_CMD		/* Console command */
151 151
 //#define IPSTAT_CMD		/* IP statistics commands */
152
+//#define PROFSTAT_CMD		/* Profiling commands */
152 153
 
153 154
 /*
154 155
  * ROM-specific options

+ 70
- 0
src/hci/commands/profstat_cmd.c Ver fichero

@@ -0,0 +1,70 @@
1
+/*
2
+ * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ */
19
+
20
+FILE_LICENCE ( GPL2_OR_LATER );
21
+
22
+#include <stdio.h>
23
+#include <getopt.h>
24
+#include <ipxe/command.h>
25
+#include <ipxe/parseopt.h>
26
+#include <usr/profstat.h>
27
+
28
+/** @file
29
+ *
30
+ * Profiling commands
31
+ *
32
+ */
33
+
34
+/** "profstat" options */
35
+struct profstat_options {};
36
+
37
+/** "profstat" option list */
38
+static struct option_descriptor profstat_opts[] = {};
39
+
40
+/** "profstat" command descriptor */
41
+static struct command_descriptor profstat_cmd =
42
+	COMMAND_DESC ( struct profstat_options, profstat_opts, 0, 0, NULL );
43
+
44
+/**
45
+ * The "profstat" command
46
+ *
47
+ * @v argc		Argument count
48
+ * @v argv		Argument list
49
+ * @ret rc		Return status code
50
+ */
51
+static int profstat_exec ( int argc, char **argv ) {
52
+	struct profstat_options opts;
53
+	int rc;
54
+
55
+	/* Parse options */
56
+	if ( ( rc = parse_options ( argc, argv, &profstat_cmd, &opts ) ) != 0 )
57
+		return rc;
58
+
59
+	profstat();
60
+
61
+	return 0;
62
+}
63
+
64
+/** Profiling commands */
65
+struct command profstat_commands[] __command = {
66
+	{
67
+		.name = "profstat",
68
+		.exec = profstat_exec,
69
+	},
70
+};

+ 14
- 0
src/include/usr/profstat.h Ver fichero

@@ -0,0 +1,14 @@
1
+#ifndef _USR_PROFSTAT_H
2
+#define _USR_PROFSTAT_H
3
+
4
+/** @file
5
+ *
6
+ * Profiling
7
+ *
8
+ */
9
+
10
+FILE_LICENCE ( GPL2_OR_LATER );
11
+
12
+extern void profstat ( void );
13
+
14
+#endif /* _USR_PROFSTAT_H */

+ 44
- 0
src/usr/profstat.c Ver fichero

@@ -0,0 +1,44 @@
1
+/*
2
+ * Copyright (C) 2014 Michael Brown <mbrown@fensystems.co.uk>.
3
+ *
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License as
6
+ * published by the Free Software Foundation; either version 2 of the
7
+ * License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful, but
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
+ * General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
+ * 02110-1301, USA.
18
+ */
19
+
20
+FILE_LICENCE ( GPL2_OR_LATER );
21
+
22
+#include <stdio.h>
23
+#include <ipxe/profile.h>
24
+#include <usr/profstat.h>
25
+
26
+/** @file
27
+ *
28
+ * Profiling
29
+ *
30
+ */
31
+
32
+/**
33
+ * Print profiling statistics
34
+ *
35
+ */
36
+void profstat ( void ) {
37
+	struct profiler *profiler;
38
+
39
+	for_each_table_entry ( profiler, PROFILERS ) {
40
+		printf ( "%s: %ld +/- %ld ticks (%d samples)\n",
41
+			 profiler->name, profile_mean ( profiler ),
42
+			 profile_stddev ( profiler ), profiler->count );
43
+	}
44
+}

Loading…
Cancelar
Guardar