Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: third_party/grpc/test/cpp/qps/qps_interarrival_test.cc

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/grpc/test/cpp/qps/qps_driver.cc ('k') | third_party/grpc/test/cpp/qps/qps_openloop_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/grpc/test/cpp/qps/qps_interarrival_test.cc
diff --git a/third_party/tcmalloc/chromium/src/base/thread_lister.c b/third_party/grpc/test/cpp/qps/qps_interarrival_test.cc
similarity index 54%
copy from third_party/tcmalloc/chromium/src/base/thread_lister.c
copy to third_party/grpc/test/cpp/qps/qps_interarrival_test.cc
index bc180dba7a9f2ba3b8261009c8af85f0b1d4a023..77e81fb84bc1a92dfcf4f4d307d584d716d73c8c 100644
--- a/third_party/tcmalloc/chromium/src/base/thread_lister.c
+++ b/third_party/grpc/test/cpp/qps/qps_interarrival_test.cc
@@ -1,4 +1,6 @@
-/* Copyright (c) 2005-2007, Google Inc.
+/*
+ *
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,51 +29,48 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * ---
- * Author: Markus Gutschke
*/
-#include "config.h"
-#include <stdio.h> /* needed for NULL on some powerpc platforms (?!) */
-#ifdef HAVE_SYS_PRCTL
-# include <sys/prctl.h>
-#endif
-#include "base/thread_lister.h"
-#include "base/linuxthreads.h"
-/* Include other thread listers here that define THREADS macro
- * only when they can provide a good implementation.
- */
+#include <chrono>
+#include <iostream>
-#ifndef THREADS
+// Use the C histogram rather than C++ to avoid depending on proto
+#include <grpc/support/histogram.h>
-/* Default trivial thread lister for single-threaded applications,
- * or if the multi-threading code has not been ported, yet.
- */
+#include "test/cpp/qps/interarrival.h"
-int ListAllProcessThreads(void *parameter,
- ListAllProcessThreadsCallBack callback, ...) {
- int rc;
- va_list ap;
- pid_t pid;
+using grpc::testing::RandomDistInterface;
+using grpc::testing::InterarrivalTimer;
-#ifdef HAVE_SYS_PRCTL
- int dumpable = prctl(PR_GET_DUMPABLE, 0);
- if (!dumpable)
- prctl(PR_SET_DUMPABLE, 1);
-#endif
- va_start(ap, callback);
- pid = getpid();
- rc = callback(parameter, 1, &pid, ap);
- va_end(ap);
-#ifdef HAVE_SYS_PRCTL
- if (!dumpable)
- prctl(PR_SET_DUMPABLE, 0);
-#endif
- return rc;
-}
+static void RunTest(RandomDistInterface &&r, int threads, std::string title) {
+ InterarrivalTimer timer;
+ timer.init(r, threads);
+ gpr_histogram *h(gpr_histogram_create(0.01, 60e9));
-int ResumeAllProcessThreads(int num_threads, pid_t *thread_pids) {
- return 1;
+ for (int i = 0; i < 10000000; i++) {
+ for (int j = 0; j < threads; j++) {
+ gpr_histogram_add(h, timer.next(j));
+ }
+ }
+
+ std::cout << title << " Distribution" << std::endl;
+ std::cout << "Value, Percentile" << std::endl;
+ for (double pct = 0.0; pct < 100.0; pct += 1.0) {
+ std::cout << gpr_histogram_percentile(h, pct) << "," << pct << std::endl;
+ }
+
+ gpr_histogram_destroy(h);
}
-#endif /* ifndef THREADS */
+using grpc::testing::ExpDist;
+using grpc::testing::DetDist;
+using grpc::testing::UniformDist;
+using grpc::testing::ParetoDist;
+
+int main(int argc, char **argv) {
+ RunTest(ExpDist(10.0), 5, std::string("Exponential(10)"));
+ RunTest(DetDist(5.0), 5, std::string("Det(5)"));
+ RunTest(UniformDist(0.0, 10.0), 5, std::string("Uniform(0,10)"));
+ RunTest(ParetoDist(1.0, 1.0), 5, std::string("Pareto(1,1)"));
+ return 0;
+}
« no previous file with comments | « third_party/grpc/test/cpp/qps/qps_driver.cc ('k') | third_party/grpc/test/cpp/qps/qps_openloop_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698