Changeset 351
- Timestamp:
- Mar 22, 2006 7:08:19 PM (19 years ago)
- Location:
- pjproject/trunk/pjlib/src/pjlib-test
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/src/pjlib-test/ioq_perf.c
r126 r351 85 85 if (bytes_read < 0) { 86 86 pj_status_t rc = -bytes_read; 87 char errmsg[ 128];87 char errmsg[PJ_ERR_MSG_SIZE]; 88 88 89 89 if (rc != last_error) { 90 90 //last_error = rc; 91 91 pj_strerror(rc, errmsg, sizeof(errmsg)); 92 PJ_LOG(3,(THIS_FILE, 92 PJ_LOG(3,(THIS_FILE,"...error: read error, bytes_read=%d (%s)", 93 93 bytes_read, errmsg)); 94 94 PJ_LOG(3,(THIS_FILE, … … 179 179 } 180 180 181 struct thread_arg 182 { 183 int id; 184 pj_ioqueue_t *ioqueue; 185 unsigned counter; 186 }; 187 181 188 /* The worker thread. */ 182 static int worker_thread(void * arg)183 { 184 pj_ioqueue_t *ioqueue = arg;189 static int worker_thread(void *p) 190 { 191 struct thread_arg *arg = p; 185 192 const pj_time_val timeout = {0, 100}; 186 193 int rc; 187 194 188 195 while (!thread_quit_flag) { 189 rc = pj_ioqueue_poll(ioqueue, &timeout); 196 197 ++arg->counter; 198 rc = pj_ioqueue_poll(arg->ioqueue, &timeout); 190 199 //TRACE_((THIS_FILE, " thread: poll returned rc=%d", rc)); 191 200 if (rc < 0) { 192 app_perror("...error in pj_ioqueue_poll()", pj_get_netos_error()); 193 return -1; 201 char errmsg[PJ_ERR_MSG_SIZE]; 202 pj_strerror(-rc, errmsg, sizeof(errmsg)); 203 PJ_LOG(3, (THIS_FILE, 204 "...error in pj_ioqueue_poll() in thread %d " 205 "after %d loop: %s [pj_status_t=%d]", 206 arg->id, arg->counter, errmsg, -rc)); 207 //return -1; 194 208 } 195 209 } … … 316 330 /* Create the threads. */ 317 331 for (i=0; i<thread_cnt; ++i) { 332 struct thread_arg *arg; 333 334 arg = pj_pool_zalloc(pool, sizeof(*arg)); 335 arg->id = i; 336 arg->ioqueue = ioqueue; 337 arg->counter = 0; 338 318 339 rc = pj_thread_create( pool, NULL, 319 340 &worker_thread, 320 ioqueue,341 arg, 321 342 PJ_THREAD_DEFAULT_STACK_SIZE, 322 343 PJ_THREAD_SUSPENDED, &thread[i] ); … … 383 404 } 384 405 406 /* Destroy threads */ 407 for (i=0; i<thread_cnt; ++i) { 408 pj_thread_destroy(thread[i]); 409 } 410 385 411 /* Destroy ioqueue. */ 386 412 TRACE_((THIS_FILE, " destroying ioqueue..")); … … 403 429 *p_bandwidth = (pj_uint32_t)bandwidth; 404 430 405 PJ_LOG(3,(THIS_FILE, " %.4s %d %d % 3d us %8d KB/s",431 PJ_LOG(3,(THIS_FILE, " %.4s %d %d %8d KB/s", 406 432 type_name, thread_cnt, sockpair_cnt, 407 -1 /*total_elapsed_usec/sockpair_cnt*/,408 433 *p_bandwidth)); 409 434 … … 441 466 { PJ_SOCK_DGRAM, "udp", 4, 4}, 442 467 { PJ_SOCK_DGRAM, "udp", 4, 8}, 468 { PJ_SOCK_DGRAM, "udp", 4, 16}, 443 469 { PJ_SOCK_STREAM, "tcp", 1, 1}, 444 470 { PJ_SOCK_STREAM, "tcp", 1, 2}, … … 453 479 { PJ_SOCK_STREAM, "tcp", 4, 4}, 454 480 { PJ_SOCK_STREAM, "tcp", 4, 8}, 481 { PJ_SOCK_STREAM, "tcp", 4, 16}, 482 /* 483 { PJ_SOCK_DGRAM, "udp", 32, 1}, 484 { PJ_SOCK_DGRAM, "udp", 32, 1}, 485 { PJ_SOCK_DGRAM, "udp", 32, 1}, 486 { PJ_SOCK_DGRAM, "udp", 32, 1}, 487 { PJ_SOCK_DGRAM, "udp", 1, 32}, 488 { PJ_SOCK_DGRAM, "udp", 1, 32}, 489 { PJ_SOCK_DGRAM, "udp", 1, 32}, 490 { PJ_SOCK_DGRAM, "udp", 1, 32}, 491 { PJ_SOCK_STREAM, "tcp", 32, 1}, 492 { PJ_SOCK_STREAM, "tcp", 32, 1}, 493 { PJ_SOCK_STREAM, "tcp", 32, 1}, 494 { PJ_SOCK_STREAM, "tcp", 32, 1}, 495 { PJ_SOCK_STREAM, "tcp", 1, 32}, 496 { PJ_SOCK_STREAM, "tcp", 1, 32}, 497 { PJ_SOCK_STREAM, "tcp", 1, 32}, 498 { PJ_SOCK_STREAM, "tcp", 1, 32}, 499 */ 455 500 }; 456 501 pj_size_t best_bandwidth; … … 458 503 459 504 PJ_LOG(3,(THIS_FILE, " Benchmarking %s ioqueue:", pj_ioqueue_name())); 460 PJ_LOG(3,(THIS_FILE, " ======================================= ========"));461 PJ_LOG(3,(THIS_FILE, " Type Threads Skt.Pairs Avg.TimeBandwidth"));462 PJ_LOG(3,(THIS_FILE, " ======================================= ========"));505 PJ_LOG(3,(THIS_FILE, " =======================================")); 506 PJ_LOG(3,(THIS_FILE, " Type Threads Skt.Pairs Bandwidth")); 507 PJ_LOG(3,(THIS_FILE, " =======================================")); 463 508 464 509 best_bandwidth = 0; … … 478 523 best_bandwidth = bandwidth, best_index = i; 479 524 480 /* Give it a rest before next test. */ 525 /* Give it a rest before next test, to allow system to close the 526 * sockets properly. 527 */ 481 528 pj_thread_sleep(500); 482 529 } -
pjproject/trunk/pjlib/src/pjlib-test/thread.c
r65 r351 126 126 } 127 127 128 pj_thread_sleep(500); 129 128 130 if (flags & PJ_THREAD_SUSPENDED) { 131 132 /* Check that counter is still zero */ 133 if (counter != 0) { 134 PJ_LOG(3,(THIS_FILE, "...error: thread is not suspended")); 135 return -1015; 136 } 137 129 138 rc = pj_thread_resume(thread); 130 139 if (rc != PJ_SUCCESS) { … … 136 145 PJ_LOG(3,(THIS_FILE, "..waiting for thread to quit..")); 137 146 147 pj_thread_sleep(500); 148 138 149 quit_flag = 1; 139 150 pj_thread_join(thread); … … 141 152 pj_pool_release(pool); 142 153 154 if (counter == 0) { 155 PJ_LOG(3,(THIS_FILE, "...error: thread is not running")); 156 return -1025; 157 } 158 143 159 PJ_LOG(3,(THIS_FILE, "...%s success", title)); 144 160 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.