summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-12-25 06:10:34 +0000
committerRoger Dingledine <arma@torproject.org>2004-12-25 06:10:34 +0000
commitbe72937ab0205359f4044c553bb172405211e6ae (patch)
tree56e50bd7301615e612526f73c4ed16ab9aca712f
parent53105cdae52b1a271d4087c6e6ffe314ea9214cc (diff)
downloadtor-be72937ab0205359f4044c553bb172405211e6ae.tar.gz
tor-be72937ab0205359f4044c553bb172405211e6ae.zip
initial profiling by phobos says we spend a whole lot of time
measuring how long each cell takes to process. make that optional. svn:r3226
-rw-r--r--src/or/command.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 1bf5d9ef0c..34fd66f89c 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -57,12 +57,15 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn, int *tim
*time += time_passed;
}
+#define KEEP_TIMING_STATS 0
+
/** Process a <b>cell</b> that was just received on <b>conn</b>. Keep internal
* statistics about how many of each cell we've processed so far
* this second, and the total number of microseconds it took to
* process each type of cell.
*/
void command_process_cell(cell_t *cell, connection_t *conn) {
+#ifdef KEEP_TIMING_STATS
/* how many of each cell have we seen so far this second? needs better
* name. */
static int num_create=0, num_created=0, num_relay=0, num_destroy=0;
@@ -87,6 +90,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) {
/* remember which second it is, for next time */
current_second = now;
}
+#endif
switch (cell->command) {
case CELL_PADDING:
@@ -95,27 +99,43 @@ void command_process_cell(cell_t *cell, connection_t *conn) {
break;
case CELL_CREATE:
++stats_n_create_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_create;
command_time_process_cell(cell, conn, &create_time,
command_process_create_cell);
+#else
+ command_process_create_cell(cell, conn);
+#endif
break;
case CELL_CREATED:
++stats_n_created_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_created;
command_time_process_cell(cell, conn, &created_time,
command_process_created_cell);
+#else
+ command_process_created_cell(cell, conn);
+#endif
break;
case CELL_RELAY:
++stats_n_relay_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_relay;
command_time_process_cell(cell, conn, &relay_time,
command_process_relay_cell);
+#else
+ command_process_relay_cell(cell, conn);
+#endif
break;
case CELL_DESTROY:
++stats_n_destroy_cells_processed;
+#ifdef KEEP_TIMING_STATS
++num_destroy;
command_time_process_cell(cell, conn, &destroy_time,
command_process_destroy_cell);
+#else
+ command_process_destroy_cell(cell, conn);
+#endif
break;
default:
log_fn(LOG_WARN,"Cell of unknown type (%d) received. Dropping.", cell->command);