Skip to content

Commit

Permalink
fix wrong test
Browse files Browse the repository at this point in the history
  • Loading branch information
owent committed May 17, 2014
1 parent 5632ffe commit 6764812
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 49 deletions.
6 changes: 3 additions & 3 deletions doc/reports/linux_start_stress_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ if [ $# -lt 2 ]; then
fi

echo "###################### context coroutine (stack using memory pool) ###################" >> "$2";
echo "########## Cmd: sample/sample_stress_test_coroutines_mem_pool 10000 1000 200" >> "$2";
"$1"/sample/sample_stress_test_coroutines_mem_pool 10000 1000 200 >> "$2";
echo "########## Cmd: sample/sample_stress_test_coroutine_mem_pool 10000 1000 200" >> "$2";
"$1"/sample/sample_stress_test_coroutine_mem_pool 10000 1000 200 >> "$2";
echo "########## Cmd: sample/sample_stress_test_coroutines_mem_pool 1000 1000 2048" >> "$2";
"$1"/sample/sample_stress_test_coroutines_mem_pool 1000 1000 2048 >> "$2";
"$1"/sample/sample_stress_test_coroutine_mem_pool 1000 1000 2048 >> "$2";
echo "" >> "$2";


Expand Down
74 changes: 37 additions & 37 deletions doc/reports/linux_stress_report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,68 @@ Run Env => thread number: 1, stack memory cost 2.0GB
Compile Options:-O2 -g -DNDEBUG -ggdb -std=gnu++11 -Wall -Werror -rdynamic -Wno-unused-local-typedefs -fsplit-stack

###################### context coroutine (stack using memory pool) ###################
########## Cmd: sample/sample_stress_test_coroutines_mem_pool 10000 1000 200
allocate 10000 coroutine, cost time: 0 s, clock time: 3 ms, avg: 300 ns
create 10000 coroutine, cost time: 0 s, clock time: 76 ms, avg: 7600 ns
switch 10000 coroutine contest 10000000 times, cost time: 4 s, clock time: 3802 ms, avg: 380 ns
remove 10000 coroutine, cost time: 0 s, clock time: 27 ms, avg: 2700 ns
########## Cmd: sample/sample_stress_test_coroutine_mem_pool 10000 1000 200
allocate 10000 coroutine, cost time: 0 s, clock time: 4 ms, avg: 400 ns
create 10000 coroutine, cost time: 0 s, clock time: 52 ms, avg: 5200 ns
switch 10000 coroutine contest 10000000 times, cost time: 6 s, clock time: 6291 ms, avg: 629 ns
remove 10000 coroutine, cost time: 0 s, clock time: 9 ms, avg: 900 ns
########## Cmd: sample/sample_stress_test_coroutines_mem_pool 1000 1000 2048
allocate 1000 coroutine, cost time: 0 s, clock time: 0 ms, avg: 0 ns
create 1000 coroutine, cost time: 0 s, clock time: 8 ms, avg: 8000 ns
switch 1000 coroutine contest 1000000 times, cost time: 1 s, clock time: 249 ms, avg: 249 ns
remove 1000 coroutine, cost time: 0 s, clock time: 4 ms, avg: 4000 ns
create 1000 coroutine, cost time: 0 s, clock time: 11 ms, avg: 11000 ns
switch 1000 coroutine contest 1000000 times, cost time: 0 s, clock time: 364 ms, avg: 364 ns
remove 1000 coroutine, cost time: 0 s, clock time: 2 ms, avg: 2000 ns

###################### context coroutine (stack using default allocator[mmap/VirtualAlloc]) ###################
###################### context coroutine (stack using default allocator[mmap]) ###################
########## Cmd: sample/sample_stress_test_coroutine 10000 1000 200
allocate 10000 coroutine, cost time: 0 s, clock time: 2 ms, avg: 200 ns
create 10000 coroutine, cost time: 0 s, clock time: 74 ms, avg: 7400 ns
switch 10000 coroutine contest 10000000 times, cost time: 3 s, clock time: 3400 ms, avg: 340 ns
remove 10000 coroutine, cost time: 0 s, clock time: 30 ms, avg: 3000 ns
create 10000 coroutine, cost time: 0 s, clock time: 76 ms, avg: 7600 ns
switch 10000 coroutine contest 10000000 times, cost time: 5 s, clock time: 4729 ms, avg: 472 ns
remove 10000 coroutine, cost time: 0 s, clock time: 32 ms, avg: 3200 ns
########## Cmd: sample/sample_stress_test_coroutine 1000 1000 2048
allocate 1000 coroutine, cost time: 0 s, clock time: 0 ms, avg: 0 ns
create 1000 coroutine, cost time: 0 s, clock time: 8 ms, avg: 8000 ns
switch 1000 coroutine contest 1000000 times, cost time: 0 s, clock time: 223 ms, avg: 223 ns
remove 1000 coroutine, cost time: 0 s, clock time: 3 ms, avg: 3000 ns
switch 1000 coroutine contest 1000000 times, cost time: 1 s, clock time: 281 ms, avg: 281 ns
remove 1000 coroutine, cost time: 0 s, clock time: 4 ms, avg: 4000 ns

###################### context coroutine (stack using malloc/free [ptmalloc]) ###################
########## Cmd: sample/sample_stress_test_coroutine_malloc 10000 1000 200
allocate 10000 coroutine, cost time: 0 s, clock time: 2 ms, avg: 200 ns
create 10000 coroutine, cost time: 0 s, clock time: 45 ms, avg: 4500 ns
switch 10000 coroutine contest 10000000 times, cost time: 4 s, clock time: 3851 ms, avg: 385 ns
remove 10000 coroutine, cost time: 0 s, clock time: 8 ms, avg: 800 ns
create 10000 coroutine, cost time: 0 s, clock time: 72 ms, avg: 7200 ns
switch 10000 coroutine contest 10000000 times, cost time: 6 s, clock time: 6291 ms, avg: 629 ns
remove 10000 coroutine, cost time: 0 s, clock time: 27 ms, avg: 2700 ns
########## Cmd: sample/sample_stress_test_coroutine_malloc 1000 1000 2048
allocate 1000 coroutine, cost time: 0 s, clock time: 0 ms, avg: 0 ns
create 1000 coroutine, cost time: 0 s, clock time: 5 ms, avg: 5000 ns
switch 1000 coroutine contest 1000000 times, cost time: 1 s, clock time: 264 ms, avg: 264 ns
remove 1000 coroutine, cost time: 0 s, clock time: 2 ms, avg: 2000 ns
create 1000 coroutine, cost time: 0 s, clock time: 8 ms, avg: 8000 ns
switch 1000 coroutine contest 1000000 times, cost time: 0 s, clock time: 335 ms, avg: 335 ns
remove 1000 coroutine, cost time: 0 s, clock time: 4 ms, avg: 4000 ns

###################### task (stack using memory pool) ###################
########## Cmd: sample/sample_stress_test_task_mem_pool 10000 1000 200
create 10000 task, cost time: 0 s, clock time: 46 ms, avg: 4600 ns
switch 10000 tasks 10000000 times, cost time: 5 s, clock time: 4952 ms, avg: 495 ns
remove 10000 tasks, cost time: 0 s, clock time: 1 ms, avg: 100 ns
create 10000 task, cost time: 0 s, clock time: 54 ms, avg: 5400 ns
switch 10000 tasks 10000000 times, cost time: 10 s, clock time: 9194 ms, avg: 919 ns
remove 10000 tasks, cost time: 0 s, clock time: 4 ms, avg: 400 ns
########## Cmd: sample/sample_stress_test_task_mem_pool 1000 1000 2048
create 1000 task, cost time: 0 s, clock time: 6 ms, avg: 6000 ns
switch 1000 tasks 1000000 times, cost time: 0 s, clock time: 351 ms, avg: 351 ns
switch 1000 tasks 1000000 times, cost time: 0 s, clock time: 654 ms, avg: 654 ns
remove 1000 tasks, cost time: 0 s, clock time: 0 ms, avg: 0 ns

###################### task (stack using default allocator[mmap/VirtualAlloc]) ###################
###################### task (stack using default allocator[mmap]) ###################
########## Cmd: sample/sample_stress_test_task 10000 1000 200
create 10000 task, cost time: 0 s, clock time: 78 ms, avg: 7800 ns
switch 10000 tasks 10000000 times, cost time: 5 s, clock time: 5350 ms, avg: 535 ns
remove 10000 tasks, cost time: 0 s, clock time: 33 ms, avg: 3300 ns
create 10000 task, cost time: 0 s, clock time: 92 ms, avg: 9200 ns
switch 10000 tasks 10000000 times, cost time: 10 s, clock time: 9341 ms, avg: 934 ns
remove 10000 tasks, cost time: 0 s, clock time: 39 ms, avg: 3900 ns
########## Cmd: sample/sample_stress_test_task 1000 1000 2048
create 1000 task, cost time: 0 s, clock time: 8 ms, avg: 8000 ns
switch 1000 tasks 1000000 times, cost time: 1 s, clock time: 354 ms, avg: 354 ns
remove 1000 tasks, cost time: 0 s, clock time: 4 ms, avg: 4000 ns
create 1000 task, cost time: 0 s, clock time: 10 ms, avg: 10000 ns
switch 1000 tasks 1000000 times, cost time: 0 s, clock time: 649 ms, avg: 649 ns
remove 1000 tasks, cost time: 0 s, clock time: 5 ms, avg: 5000 ns

###################### task (stack using malloc/free [ptmalloc]) ###################
########## Cmd: sample/sample_stress_test_task_malloc 10000 1000 200
create 10000 task, cost time: 0 s, clock time: 73 ms, avg: 7300 ns
switch 10000 tasks 10000000 times, cost time: 5 s, clock time: 5037 ms, avg: 503 ns
remove 10000 tasks, cost time: 0 s, clock time: 30 ms, avg: 3000 ns
create 10000 task, cost time: 0 s, clock time: 82 ms, avg: 8200 ns
switch 10000 tasks 10000000 times, cost time: 10 s, clock time: 9243 ms, avg: 924 ns
remove 10000 tasks, cost time: 0 s, clock time: 35 ms, avg: 3500 ns
########## Cmd: sample/sample_stress_test_task_malloc 1000 1000 2048
create 1000 task, cost time: 0 s, clock time: 8 ms, avg: 8000 ns
switch 1000 tasks 1000000 times, cost time: 0 s, clock time: 354 ms, avg: 354 ns
remove 1000 tasks, cost time: 0 s, clock time: 4 ms, avg: 4000 ns
create 1000 task, cost time: 0 s, clock time: 9 ms, avg: 9000 ns
switch 1000 tasks 1000000 times, cost time: 0 s, clock time: 665 ms, avg: 665 ns
remove 1000 tasks, cost time: 0 s, clock time: 5 ms, avg: 5000 ns

9 changes: 1 addition & 8 deletions sample/sample_stress_test_coroutine_malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int switch_count = 100;

typedef copp::detail::coroutine_context_container<
copp::detail::coroutine_context_safe_base,
copp::allocator::stack_allocator_memory
copp::allocator::stack_allocator_malloc
> my_cotoutine_t;

// define a coroutine runner
Expand All @@ -48,9 +48,6 @@ int MAX_COROUTINE_NUMBER = 100000; // 协程数量
my_cotoutine_t* co_arr = NULL;
my_runner* runner = NULL;

// === 栈内存池 ===
char * stack_mem_pool = NULL;

int main(int argc, char* argv[]) {
if (argc > 1) {
MAX_COROUTINE_NUMBER = atoi(argv[1]);
Expand All @@ -65,8 +62,6 @@ int main(int argc, char* argv[]) {
stack_size = atoi(argv[3]) * 1024;
}

stack_mem_pool = new char[MAX_COROUTINE_NUMBER * stack_size];

time_t begin_time = time(NULL);
clock_t begin_clock = clock();

Expand All @@ -86,7 +81,6 @@ int main(int argc, char* argv[]) {
// create a runner
// bind runner to coroutine object
for (int i = 0; i < MAX_COROUTINE_NUMBER; ++ i) {
co_arr[i].get_allocator().attach(stack_mem_pool + i * stack_size, stack_size);
co_arr[i].create(&runner[i], stack_size);
}

Expand Down Expand Up @@ -137,7 +131,6 @@ int main(int argc, char* argv[]) {

delete []co_arr;
delete []runner;
delete []stack_mem_pool;

end_time = time(NULL);
end_clock = clock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int switch_count = 100;

typedef copp::detail::coroutine_context_container<
copp::detail::coroutine_context_safe_base,
copp::allocator::stack_allocator_malloc
copp::allocator::stack_allocator_memory
> my_cotoutine_t;

// define a coroutine runner
Expand All @@ -48,6 +48,9 @@ int MAX_COROUTINE_NUMBER = 100000; // 协程数量
my_cotoutine_t* co_arr = NULL;
my_runner* runner = NULL;

// === 栈内存池 ===
char * stack_mem_pool = NULL;

int main(int argc, char* argv[]) {
if (argc > 1) {
MAX_COROUTINE_NUMBER = atoi(argv[1]);
Expand All @@ -62,6 +65,8 @@ int main(int argc, char* argv[]) {
stack_size = atoi(argv[3]) * 1024;
}

stack_mem_pool = new char[MAX_COROUTINE_NUMBER * stack_size];

time_t begin_time = time(NULL);
clock_t begin_clock = clock();

Expand All @@ -81,6 +86,7 @@ int main(int argc, char* argv[]) {
// create a runner
// bind runner to coroutine object
for (int i = 0; i < MAX_COROUTINE_NUMBER; ++ i) {
co_arr[i].get_allocator().attach(stack_mem_pool + i * stack_size, stack_size);
co_arr[i].create(&runner[i], stack_size);
}

Expand Down Expand Up @@ -131,6 +137,7 @@ int main(int argc, char* argv[]) {

delete []co_arr;
delete []runner;
delete []stack_mem_pool;

end_time = time(NULL);
end_clock = clock();
Expand Down

0 comments on commit 6764812

Please sign in to comment.