diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-12-06 22:38:55 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-12-06 22:38:55 +0000 |
commit | c00d64010a139d32b577e7ad422aceace4edd686 (patch) | |
tree | 55526a18a04ad004c0ebee5769764d8158c078da /src/fs/gnunet-fs-profiler.c | |
parent | 90913a15275c8659008909068512b015e08c0bd8 (diff) | |
download | gnunet-c00d64010a139d32b577e7ad422aceace4edd686.tar.gz gnunet-c00d64010a139d32b577e7ad422aceace4edd686.zip |
-skeleton
Diffstat (limited to 'src/fs/gnunet-fs-profiler.c')
-rw-r--r-- | src/fs/gnunet-fs-profiler.c | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/fs/gnunet-fs-profiler.c b/src/fs/gnunet-fs-profiler.c new file mode 100644 index 000000000..a7ef7786d --- /dev/null +++ b/src/fs/gnunet-fs-profiler.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file fs/gnunet-fs-profiler.c | ||
23 | * @brief tool to benchmark/profile file-sharing | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #include "platform.h" | ||
27 | #include "gnunet_util_lib.h" | ||
28 | #include "gnunet_testbed_service.h" | ||
29 | |||
30 | /** | ||
31 | * Final status code. | ||
32 | */ | ||
33 | static int ret; | ||
34 | |||
35 | /** | ||
36 | * Data file with the hosts for the testbed. | ||
37 | */ | ||
38 | static char *host_filename; | ||
39 | |||
40 | /** | ||
41 | * Number of peers to run in the experiment. | ||
42 | */ | ||
43 | static unsigned int num_peers; | ||
44 | |||
45 | |||
46 | /** | ||
47 | * The testbed has been started, now begin the experiment. | ||
48 | * | ||
49 | * @param cls configuration handle | ||
50 | * @param tc scheduler context | ||
51 | */ | ||
52 | static void | ||
53 | master_task (void *cls, | ||
54 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
55 | { | ||
56 | // const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | ||
57 | |||
58 | GNUNET_SCHEDULER_shutdown (); | ||
59 | } | ||
60 | |||
61 | |||
62 | /** | ||
63 | * Main function that will be run by the scheduler. | ||
64 | * | ||
65 | * @param cls closure | ||
66 | * @param args remaining command-line arguments | ||
67 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
68 | * @param cfg configuration | ||
69 | */ | ||
70 | static void | ||
71 | run (void *cls, char *const *args, const char *cfgfile, | ||
72 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
73 | { | ||
74 | GNUNET_TESTBED_run (host_filename, | ||
75 | cfg, | ||
76 | num_peers, | ||
77 | 0, NULL, NULL, | ||
78 | &master_task, (void *) cfg); | ||
79 | } | ||
80 | |||
81 | |||
82 | /** | ||
83 | * Program to run a file-sharing testbed. | ||
84 | * | ||
85 | * @param argc number of arguments from the command line | ||
86 | * @param argv command line arguments | ||
87 | * @return 0 ok, 1 on error | ||
88 | */ | ||
89 | int | ||
90 | main (int argc, char *const *argv) | ||
91 | { | ||
92 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
93 | {'n', "num-peers", "COUNT", | ||
94 | gettext_noop ("run the experiment with COUNT peers"), | ||
95 | 1, &GNUNET_GETOPT_set_uint, &num_peers}, | ||
96 | {'t', "testbed", "HOSTFILE", | ||
97 | gettext_noop ("specifies name of a file with the HOSTS the testbed should use"), | ||
98 | 1, &GNUNET_GETOPT_set_string, &host_filename}, | ||
99 | |||
100 | GNUNET_GETOPT_OPTION_END | ||
101 | }; | ||
102 | if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv)) | ||
103 | return 2; | ||
104 | |||
105 | ret = (GNUNET_OK == | ||
106 | GNUNET_PROGRAM_run (argc, argv, "gnunet-fs-profiler", | ||
107 | gettext_noop ("run a testbed to measure file-sharing performance"), options, &run, | ||
108 | NULL)) ? ret : 1; | ||
109 | GNUNET_free ((void*) argv); | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | /* end of gnunet-fs-profiler.c */ | ||