Skip to content

Commit

Permalink
Add parameters to ut-memory parallel test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mortal committed Dec 10, 2012
1 parent 45d1c1c commit 8a12f72
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/unit/test_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <tpie/internal_vector.h>
#include <boost/random.hpp>
#include <tpie/job.h>
#include <tpie/cpu_timer.h>

struct mtest {
size_t & r;
Expand Down Expand Up @@ -163,9 +164,9 @@ class memory_user : public tpie::job {
}
};

bool parallel_test(size_t nJobs) {
const size_t times = 500000;
const size_t capacity = 50000;
bool parallel_test(const size_t nJobs, const size_t times, const size_t capacity) {
tpie::cpu_timer t;
t.start();
tpie::internal_vector<memory_user *> workers(nJobs);
for (size_t i = 0; i < nJobs; ++i) {
workers[i] = tpie::tpie_new<memory_user>(times, capacity);
Expand All @@ -175,12 +176,14 @@ bool parallel_test(size_t nJobs) {
workers[i]->join();
tpie::tpie_delete(workers[i]);
}
t.stop();
tpie::log_info() << t << std::endl;
return true;
}

int main(int argc, char ** argv) {
return tpie::tests(argc, argv, 128)
.test(basic_test, "basic")
.test(parallel_test, "parallel", "n", static_cast<size_t>(8))
.test(parallel_test, "parallel", "n", static_cast<size_t>(8), "times", static_cast<size_t>(500000), "capacity", static_cast<size_t>(50000))
;
}

0 comments on commit 8a12f72

Please sign in to comment.