diff options
author | Christian Grothoff <christian@grothoff.org> | 2007-02-25 01:00:12 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2007-02-25 01:00:12 +0000 |
commit | 61cdd87fafb613565dd61f974494e7a4a5e4b61f (patch) | |
tree | 92c462ad20077244179c399f295382bad6ae54f2 | |
parent | 2c9ed615b12f3da13add937c877047c857affee6 (diff) | |
download | gnunet-gtk-61cdd87fafb613565dd61f974494e7a4a5e4b61f.tar.gz gnunet-gtk-61cdd87fafb613565dd61f974494e7a4a5e4b61f.zip |
bugfixes and various improvements
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | src/plugins/stats/functions.c | 38 |
2 files changed, 32 insertions, 10 deletions
@@ -1,3 +1,7 @@ | |||
1 | Sat Feb 24 15:43:14 MST 2007 | ||
2 | Improved performance of statistics querying code | ||
3 | (O(n^2) to O(n) where n is number of stats). | ||
4 | |||
1 | Thu Feb 15 21:54:15 MST 2007 | 5 | Thu Feb 15 21:54:15 MST 2007 |
2 | Added IO load statistics. | 6 | Added IO load statistics. |
3 | 7 | ||
diff --git a/src/plugins/stats/functions.c b/src/plugins/stats/functions.c index c3f4a9ee..846dd67b 100644 --- a/src/plugins/stats/functions.c +++ b/src/plugins/stats/functions.c | |||
@@ -440,19 +440,36 @@ static int getEffectivenessStats(const void * closure, | |||
440 | return OK; | 440 | return OK; |
441 | } | 441 | } |
442 | 442 | ||
443 | |||
444 | static int statsProcessor(const char * optName, | 443 | static int statsProcessor(const char * optName, |
445 | unsigned long long value, | 444 | unsigned long long value, |
446 | void * data) { | 445 | void * data) { |
447 | cron_t * delta = data; | 446 | /** |
447 | * Keep track of last match (or, more precisely, position | ||
448 | * of next expected match) since 99.99% of the time we | ||
449 | * go over the same stats in the same order and thus | ||
450 | * this will predict correctly). | ||
451 | */ | ||
452 | static unsigned int last; | ||
453 | cron_t * delta = data; | ||
448 | int j; | 454 | int j; |
449 | int found; | 455 | int found; |
450 | 456 | ||
457 | if (last >= lsv_size) | ||
458 | last = 0; | ||
459 | j = last; | ||
451 | found = -1; | 460 | found = -1; |
452 | for (j=0;j<lsv_size;j++) | 461 | if (0 == strcmp(optName, |
453 | if (0 == strcmp(optName, | 462 | lastStatValues[j].statName)) |
454 | lastStatValues[j].statName)) | 463 | found = j; |
455 | found = j; | 464 | if (found == -1) { |
465 | for (j=0;j<lsv_size;j++) { | ||
466 | if (0 == strcmp(optName, | ||
467 | lastStatValues[j].statName)) { | ||
468 | found = j; | ||
469 | break; | ||
470 | } | ||
471 | } | ||
472 | } | ||
456 | if (found == -1) { | 473 | if (found == -1) { |
457 | found = lsv_size; | 474 | found = lsv_size; |
458 | GROW(lastStatValues, | 475 | GROW(lastStatValues, |
@@ -467,6 +484,7 @@ static int statsProcessor(const char * optName, | |||
467 | = value; | 484 | = value; |
468 | lastStatValues[found].delta | 485 | lastStatValues[found].delta |
469 | = *delta; | 486 | = *delta; |
487 | last = found + 1; | ||
470 | return OK; | 488 | return OK; |
471 | } | 489 | } |
472 | 490 | ||
@@ -481,10 +499,10 @@ static void updateStatValues(void * unused) { | |||
481 | now = get_time(); | 499 | now = get_time(); |
482 | delta = now - lastUpdate; | 500 | delta = now - lastUpdate; |
483 | MUTEX_LOCK(lock); | 501 | MUTEX_LOCK(lock); |
484 | if (OK == requestStatistics(ectx, | 502 | if (OK == STATS_getStatistics(ectx, |
485 | sock, | 503 | sock, |
486 | &statsProcessor, | 504 | &statsProcessor, |
487 | &delta)) | 505 | &delta)) |
488 | lastUpdate = now; | 506 | lastUpdate = now; |
489 | MUTEX_UNLOCK(lock); | 507 | MUTEX_UNLOCK(lock); |
490 | } | 508 | } |