diff options
author | 2015-09-22 10:42:19 -0700 | |
---|---|---|
committer | 2015-09-22 10:42:19 -0700 | |
commit | 45724b35e411fef7c5da66a74c78428c11d56843 (patch) | |
tree | 9264034aca675c89444e02f72ef58e67d7043604 /src/core/iomgr/time_averaged_stats.c | |
parent | 298751c1195523ef6228595043b583c3a6270e08 (diff) |
indent pass to get logical source lines on one physical line
Diffstat (limited to 'src/core/iomgr/time_averaged_stats.c')
-rw-r--r-- | src/core/iomgr/time_averaged_stats.c | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/src/core/iomgr/time_averaged_stats.c b/src/core/iomgr/time_averaged_stats.c index f881dde9fc..c2d1cdf212 100644 --- a/src/core/iomgr/time_averaged_stats.c +++ b/src/core/iomgr/time_averaged_stats.c @@ -33,9 +33,9 @@ #include "src/core/iomgr/time_averaged_stats.h" -void grpc_time_averaged_stats_init(grpc_time_averaged_stats *stats, - double init_avg, double regress_weight, - double persistence_factor) { +void +grpc_time_averaged_stats_init (grpc_time_averaged_stats * stats, double init_avg, double regress_weight, double persistence_factor) +{ stats->init_avg = init_avg; stats->regress_weight = regress_weight; stats->persistence_factor = persistence_factor; @@ -45,31 +45,33 @@ void grpc_time_averaged_stats_init(grpc_time_averaged_stats *stats, stats->aggregate_weighted_avg = init_avg; } -void grpc_time_averaged_stats_add_sample(grpc_time_averaged_stats *stats, - double value) { +void +grpc_time_averaged_stats_add_sample (grpc_time_averaged_stats * stats, double value) +{ stats->batch_total_value += value; ++stats->batch_num_samples; } -double grpc_time_averaged_stats_update_average( - grpc_time_averaged_stats *stats) { +double +grpc_time_averaged_stats_update_average (grpc_time_averaged_stats * stats) +{ /* Start with the current batch: */ double weighted_sum = stats->batch_total_value; double total_weight = stats->batch_num_samples; - if (stats->regress_weight > 0) { - /* Add in the regression towards init_avg_: */ - weighted_sum += stats->regress_weight * stats->init_avg; - total_weight += stats->regress_weight; - } - if (stats->persistence_factor > 0) { - /* Add in the persistence: */ - const double prev_sample_weight = - stats->persistence_factor * stats->aggregate_total_weight; - weighted_sum += prev_sample_weight * stats->aggregate_weighted_avg; - total_weight += prev_sample_weight; - } - stats->aggregate_weighted_avg = - (total_weight > 0) ? (weighted_sum / total_weight) : stats->init_avg; + if (stats->regress_weight > 0) + { + /* Add in the regression towards init_avg_: */ + weighted_sum += stats->regress_weight * stats->init_avg; + total_weight += stats->regress_weight; + } + if (stats->persistence_factor > 0) + { + /* Add in the persistence: */ + const double prev_sample_weight = stats->persistence_factor * stats->aggregate_total_weight; + weighted_sum += prev_sample_weight * stats->aggregate_weighted_avg; + total_weight += prev_sample_weight; + } + stats->aggregate_weighted_avg = (total_weight > 0) ? (weighted_sum / total_weight) : stats->init_avg; stats->aggregate_total_weight = total_weight; stats->batch_num_samples = 0; stats->batch_total_value = 0; |