Skip to content

Commit

Permalink
Merge pull request grpc#837 from ctiller/qps_driver
Browse files Browse the repository at this point in the history
QPS driver
  • Loading branch information
vjpai committed Mar 5, 2015
2 parents e7a523e + 43ef582 commit 0bc6805
Showing 23 changed files with 1,730 additions and 960 deletions.
208 changes: 92 additions & 116 deletions Makefile

Large diffs are not rendered by default.

68 changes: 27 additions & 41 deletions build.json
Original file line number Diff line number Diff line change
@@ -477,6 +477,20 @@
"gpr"
]
},
{
"name": "qps",
"build": "private",
"language": "c++",
"headers": [
"test/cpp/qps/driver.h",
"test/cpp/qps/timer.h"
],
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/driver.cc",
"test/cpp/qps/timer.cc"
]
},
{
"name": "grpc_csharp_ext",
"build": "all",
@@ -1805,15 +1819,15 @@
]
},
{
"name": "qps_client",
"name": "qps_driver",
"build": "test",
"run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/client.cc"
"test/cpp/qps/qps_driver.cc"
],
"deps": [
"qps",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
@@ -1823,51 +1837,23 @@
]
},
{
"name": "qps_client_async",
"name": "qps_worker",
"build": "test",
"run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/client_async.cc"
],
"deps": [
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
]
},
{
"name": "qps_server",
"build": "test",
"run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/server.cc"
"headers": [
"test/cpp/qps/client.h",
"test/cpp/qps/server.h"
],
"deps": [
"grpc++_test_util",
"grpc_test_util",
"grpc++",
"grpc",
"gpr_test_util",
"gpr"
]
},
{
"name": "qps_server_async",
"build": "test",
"run": false,
"language": "c++",
"src": [
"test/cpp/qps/qpstest.proto",
"test/cpp/qps/server_async.cc"
"test/cpp/qps/client_async.cc",
"test/cpp/qps/client_sync.cc",
"test/cpp/qps/server_async.cc",
"test/cpp/qps/server_sync.cc",
"test/cpp/qps/worker.cc"
],
"deps": [
"qps",
"grpc++_test_util",
"grpc_test_util",
"grpc++",
10 changes: 10 additions & 0 deletions include/grpc/support/histogram.h
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@
#ifndef GRPC_SUPPORT_HISTOGRAM_H
#define GRPC_SUPPORT_HISTOGRAM_H

#include <grpc/support/port_platform.h>
#include <stddef.h>

#ifdef __cplusplus
extern "C" {
#endif
@@ -59,6 +62,13 @@ double gpr_histogram_count(gpr_histogram *histogram);
double gpr_histogram_sum(gpr_histogram *histogram);
double gpr_histogram_sum_of_squares(gpr_histogram *histogram);

const gpr_uint32 *gpr_histogram_get_contents(gpr_histogram *histogram,
size_t *count);
void gpr_histogram_merge_contents(gpr_histogram *histogram,
const gpr_uint32 *data, size_t data_count,
double min_seen, double max_seen, double sum,
double sum_of_squares, double count);

#ifdef __cplusplus
}
#endif
35 changes: 25 additions & 10 deletions src/core/support/histogram.c
Original file line number Diff line number Diff line change
@@ -126,25 +126,35 @@ void gpr_histogram_add(gpr_histogram *h, double x) {
}

int gpr_histogram_merge(gpr_histogram *dst, gpr_histogram *src) {
size_t i;
if ((dst->num_buckets != src->num_buckets) ||
(dst->multiplier != src->multiplier)) {
/* Fail because these histograms don't match */
return 0;
}
dst->sum += src->sum;
dst->sum_of_squares += src->sum_of_squares;
dst->count += src->count;
if (src->min_seen < dst->min_seen) {
dst->min_seen = src->min_seen;
gpr_histogram_merge_contents(dst, src->buckets, src->num_buckets,
src->min_seen, src->max_seen, src->sum,
src->sum_of_squares, src->count);
return 1;
}

void gpr_histogram_merge_contents(gpr_histogram *dst, const gpr_uint32 *data,
size_t data_count, double min_seen,
double max_seen, double sum,
double sum_of_squares, double count) {
size_t i;
GPR_ASSERT(dst->num_buckets == data_count);
dst->sum += sum;
dst->sum_of_squares += sum_of_squares;
dst->count += count;
if (min_seen < dst->min_seen) {
dst->min_seen = min_seen;
}
if (src->max_seen > dst->max_seen) {
dst->max_seen = src->max_seen;
if (max_seen > dst->max_seen) {
dst->max_seen = max_seen;
}
for (i = 0; i < dst->num_buckets; i++) {
dst->buckets[i] += src->buckets[i];
dst->buckets[i] += data[i];
}
return 1;
}

static double threshold_for_count_below(gpr_histogram *h, double count_below) {
@@ -222,3 +232,8 @@ double gpr_histogram_sum(gpr_histogram *h) { return h->sum; }
double gpr_histogram_sum_of_squares(gpr_histogram *h) {
return h->sum_of_squares;
}

const gpr_uint32 *gpr_histogram_get_contents(gpr_histogram *h, size_t *size) {
*size = h->num_buckets;
return h->buckets;
}
2 changes: 1 addition & 1 deletion test/core/util/grpc_profiler.c
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@ void grpc_profiler_stop() { ProfilerStop(); }

void grpc_profiler_start(const char *filename) {
gpr_log(GPR_DEBUG,
"You do not have google-perftools installed, profiling is disabled");
"You do not have google-perftools installed, profiling is disabled [for %s]", filename);
gpr_log(GPR_DEBUG,
"To install on ubuntu: sudo apt-get install google-perftools "
"libgoogle-perftools-dev");
Loading

0 comments on commit 0bc6805

Please sign in to comment.