My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
profiler.c
Go to the documentation of this file.
1 /*
2 START OF LICENSE STUB
3  DeDOS: Declarative Dispersion-Oriented Software
4  Copyright (C) 2017 University of Pennsylvania, Georgetown University
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 END OF LICENSE STUB
19 */
25 #include "profiler.h"
26 #include "stats.h"
27 #include "logging.h"
28 #include "rt_stats.h"
29 
31 static float tag_probability = -1;
32 
41 };
42 #define N_PROF_STAT_IDS sizeof(profiler_stat_ids) / sizeof(*profiler_stat_ids)
43 
45 void set_profiling(struct msu_msg_hdr *hdr) {
46 #ifdef DEDOS_PROFILER
47  float r = (float)rand() / (float)RAND_MAX;
48  if (r > tag_probability) {
49  hdr->do_profile = false;
50  return;
51  }
52  hdr->do_profile = true;
53 #endif
54  return;
55 }
56 
58 void init_profiler(float tag_prob) {
59  if (tag_probability != -1) {
60  log_warn("Profiler initialized twice!");
61  }
62  tag_probability = tag_prob;
63  srand(time(NULL));
64 
65  for (int i=0; i<N_PROF_STAT_IDS; i++) {
67  }
68 }
Collecting statistics within the runtime.
Header for messages passed to MSUs.
Definition: msu_message.h:85
void set_profiling(struct msu_msg_hdr *hdr)
Sets the profiling flag on the header based on the tag_probability.
Definition: profiler.c:45
enum stat_id profiler_stat_ids[]
The stat IDs relevant to profiling.
Definition: profiler.c:34
Profiling.
Definition: stat_ids.h:60
stat_id
The identifiers with which stats can be logged.
Definition: stat_ids.h:32
Logging of status messages to the terminal.
void init_profiler(float tag_prob)
Initializes the profiler to tag headers with tag_prob probability.
Definition: profiler.c:58
Functions for the sending and receiving of statistics between ctrl and runtime.
For profiling the path of MSU messages through DeDOS.
static float tag_probability
The probability that an MSU message will get marked for profiling.
Definition: profiler.c:31
int init_stat_item(enum stat_id stat_id, unsigned int item_id)
Initializes a stat item so that statistics can be logged to it.
Definition: rt_stats.c:719
Profiling.
Definition: stat_ids.h:68
Profiling.
Definition: stat_ids.h:62
Profiling.
Definition: stat_ids.h:58
Profiling.
Definition: stat_ids.h:66
#define PROFILER_ITEM_ID
The ID with which all profiled messages are tagged in the stats module.
Definition: profiler.h:34
#define N_PROF_STAT_IDS
Definition: profiler.c:42
Profiling.
Definition: stat_ids.h:64
#define log_warn(fmt,...)
Definition: logging.h:113