autoconf/automake/libtool-ized thrift cpp bits:
Fixed to build on solaris.
Used clock_gettime() where available
Fixed rounding of time to ms
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664733 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/test/Tests.cc b/lib/cpp/src/concurrency/test/Tests.cc
index 19e1f4a..5c4dd24 100644
--- a/lib/cpp/src/concurrency/test/Tests.cc
+++ b/lib/cpp/src/concurrency/test/Tests.cc
@@ -1,4 +1,5 @@
#include <iostream>
+#include <vector>
#include <string>
#include "ThreadFactoryTests.h"
@@ -9,27 +10,22 @@
std::string arg;
- if(argc < 2) {
+ std::vector<std::string> args(argc - 1 > 1 ? argc - 1 : 1);
- arg = "all";
+ args[0] = "all";
- } else {
-
- arg = std::string(argv[1]);
+ for(int ix = 1; ix < argc; ix++) {
+ args[ix - 1] = std::string(argv[ix]);
}
- bool runAll = arg.compare("all") == 0;
+ bool runAll = args[0].compare("all") == 0;
- if(runAll || arg.compare("thread-factory") == 0) {
+ if(runAll || args[0].compare("thread-factory") == 0) {
ThreadFactoryTests threadFactoryTests;
std::cout << "ThreadFactory tests..." << std::endl;
- std::cout << "\tThreadFactory hello-world test" << std::endl;
-
- assert(threadFactoryTests.helloWorldTest());
-
size_t count = 1000;
std::cout << "\t\tThreadFactory reap N threads test: N = " << count << std::endl;
@@ -39,9 +35,37 @@
std::cout << "\t\tThreadFactory synchronous start test" << std::endl;
assert(threadFactoryTests.synchStartTest());
+
+ std::cout << "\t\tThreadFactory monitor timeout test" << std::endl;
+
+ assert(threadFactoryTests.monitorTimeoutTest());
}
- if(runAll || arg.compare("timer-manager") == 0) {
+ if(runAll || args[0].compare("util") == 0) {
+
+ std::cout << "Util tests..." << std::endl;
+
+ std::cout << "\t\tUtil minimum time" << std::endl;
+
+ long long time00 = Util::currentTime();
+ long long time01 = Util::currentTime();
+
+ std::cout << "\t\t\tMinimum time: " << time01 - time00 << "ms" << std::endl;
+
+ time00 = Util::currentTime();
+ time01 = time00;
+ size_t count = 0;
+
+ while(time01 < time00 + 10) {
+ count++;
+ time01 = Util::currentTime();
+ }
+
+ std::cout << "\t\t\tscall per ms: " << count / (time01 - time00) << std::endl;
+ }
+
+
+ if(runAll || args[0].compare("timer-manager") == 0) {
std::cout << "TimerManager tests..." << std::endl;
@@ -52,21 +76,51 @@
assert(timerManagerTests.test00());
}
- if(runAll || arg.compare("thread-manager") == 0) {
+ if(runAll || args[0].compare("thread-manager") == 0) {
std::cout << "ThreadManager tests..." << std::endl;
- size_t workerCount = 100;
+ {
- size_t taskCount = 100000;
+ size_t workerCount = 100;
- long long delay = 10LL;
+ size_t taskCount = 100000;
- std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+ long long delay = 10LL;
- ThreadManagerTests threadManagerTests;
+ std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
- assert(threadManagerTests.loadTest(taskCount, delay, workerCount));
+ ThreadManagerTests threadManagerTests;
+
+ assert(threadManagerTests.loadTest(taskCount, delay, workerCount));
+ }
+ }
+
+ if(runAll || args[0].compare("thread-manager-benchmark") == 0) {
+
+ std::cout << "ThreadManager benchmark tests..." << std::endl;
+
+ {
+
+ size_t minWorkerCount = 2;
+
+ size_t maxWorkerCount = 512;
+
+ size_t tasksPerWorker = 1000;
+
+ long long delay = 10LL;
+
+ for(size_t workerCount = minWorkerCount; workerCount < maxWorkerCount; workerCount*= 2) {
+
+ size_t taskCount = workerCount * tasksPerWorker;
+
+ std::cout << "\t\tThreadManager load test: worker count: " << workerCount << " task count: " << taskCount << " delay: " << delay << std::endl;
+
+ ThreadManagerTests threadManagerTests;
+
+ threadManagerTests.loadTest(taskCount, delay, workerCount);
+ }
+ }
}
}