/* callback for an expired dialog. */ static void cdr_on_expired( struct dlg_cell* dialog, int type, struct dlg_cb_params* params) { if( !dialog || !params) { LM_ERR("invalid values\n!"); return; } LM_DBG("dialog '%p' expired!\n", dialog); /* compute duration for timed out acknowledged dialog */ if ( params && params->dlg_data ) { if ( (void*)CONFIRMED_DIALOG_STATE == params->dlg_data) { if( set_end_time( dialog) != 0) { LM_ERR( "failed to set end time!\n"); return; } if( set_duration( dialog) != 0) { LM_ERR( "failed to set duration!\n"); return; } } } if( cdr_expired_dlg_enable && (write_cdr( dialog, 0) != 0)) { LM_ERR( "failed to write cdr!\n"); return; } }
void profile_ops_stop(nialptr entr) { set_end_time(current_node, profile_time()); add_time(current_node); inc_total_calls(current_node); current_node = current_node->parent; }
void GCStatInfo::copy_stat(GCStatInfo* stat) { set_index(stat->gc_index()); set_start_time(stat->start_time()); set_end_time(stat->end_time()); assert(_usage_array_size == stat->usage_array_size(), "Must have same array size"); for (int i = 0; i < _usage_array_size; i++) { set_before_gc_usage(i, stat->before_gc_usage_for_pool(i)); set_after_gc_usage(i, stat->after_gc_usage_for_pool(i)); } }
void isetprofile() { nialptr z; int tv, oldprofile = profile; /* old value of profiling switch */ z = apop(); if (kind(z) == inttype) tv = intval(z); else if (kind(z) == booltype) tv = boolval(z); else { buildfault("invalid arg to setprofile"); return; } if (tv && !oldprofile) { /* turning on profiling */ profile = true; if (newprofile) { inittime(); calltree = make_node(); current_node = calltree; /* initialize first node */ set_opid(calltree, 0); /* doesn't correspond to a defn */ set_start_time(calltree, profile_time()); /* nprintf(OF_DEBUG,"start time for call tree%f\n",calltree->start_time); */ swplace = 0; #ifdef OLD_BUILD_SYMBOL_TABLE build_symbol_table(); #endif newprofile = false; } } else if (oldprofile != false) { double lasttime = profile_time(); profile = false; if (current_node != calltree) { exit_cover(NC_PROFILE_SYNCH_W); } set_end_time(calltree, lasttime); add_time(calltree); } apush(createbool(oldprofile)); }
/* callback for the end of a dialog (BYE). */ static void cdr_on_end( struct dlg_cell* dialog, int type, struct dlg_cb_params* params) { if( !dialog || !params || !params->req) { LM_ERR("invalid values\n!"); return; } if( set_end_time( dialog) != 0) { LM_ERR( "failed to set end time!\n"); return; } if( set_duration( dialog) != 0) { LM_ERR( "failed to set duration!\n"); return; } }
void ri_timer_end(ri_timer_t *timer, const char *name) { timerinfo_t *p; ri_log_and_return_if(name == NULL); p = ri_hash_lookup(timer->entrylist, name); if (p == NULL) { printf("name = %s\n", name); ri_log(LOG_WARN, "timer is not started"); return; } else { if (!p->starting) { ri_log(LOG_WARN, "timer is not started"); return; } set_end_time(p); p->count++; p->elapsed += calc_elapsed_time(p); } }
// O primeiro parâmetro é o tamanho do vetor, e o segundo é o número de threads. int main(int argc, char *argv[]) { if (argc!=3) { printf("Número incorreto de parâmetros\n"); printf("Uso: ./<nome do programa> <ordem da matriz> <qtd. de threads>\n"); return 0; } int thread_quantity, sum, sum_thread=0, counter; int offset=0, partition_size; long int **matrix_copy; int_tuple *offset_vector; double time_main, time_thread; // Um vetor de pthreads permite a criação dinâmica de threads. pthread_t *thread_vector; sscanf(argv[1],"%d",&matrix_size); sscanf(argv[2],"%d",&thread_quantity); printf("Criando dados para as matrizes... "); thread_vector=(pthread_t*)malloc(sizeof(pthread_t)*thread_quantity); offset_vector=(int_tuple*)malloc(sizeof(int_tuple)*thread_quantity); partition_size=matrix_size/thread_quantity; partition_size--; for(counter=0; counter<thread_quantity-1; counter++) { offset_vector[counter].start=offset; offset=offset+partition_size; offset_vector[counter].end=offset; offset++; } offset_vector[thread_quantity-1].start=offset; offset_vector[thread_quantity-1].end=matrix_size-1; matrix_a=create_random_matrix(); matrix_b=create_random_matrix(); printf("feito.\n\n"); matrix_result=(long int**)malloc(sizeof(long int*)*matrix_size); for(counter=0; counter<matrix_size; counter++) matrix_result[counter]=(long int*)malloc(sizeof(long int)*matrix_size); printf("Iniciando as contas na função main().\n"); set_start_time(); multiply_matrix(); set_end_time(); time_main=end_time-start_time; printf("As contas na main() foram finalizadas.\n"); /* Aloca uma nova matriz para fazer uma cópia do resultado. * Isso é feito para saber se a multiplicação está igual. */ matrix_copy=(long int**)malloc(sizeof(long int*)*matrix_size); for(counter=0; counter<matrix_size; counter++) matrix_copy[counter]=(long int*)malloc(sizeof(long int)*matrix_size); for(counter=0; counter<matrix_size; counter++) { for(offset=0; offset<matrix_size; offset++) matrix_copy[counter][offset]=matrix_result[counter][offset]; } printf("\nIniciando as contas com %d threads.\n",thread_quantity); // Inicia as contas com as threads, assim como a marcação de tempo. set_start_time(); for(counter=0; counter<thread_quantity; counter++) pthread_create(thread_vector+counter,NULL,threaded_matrix_multiplier,(void*)(offset_vector+counter)); for(counter=0; counter<thread_quantity; counter++) pthread_join(thread_vector[counter],NULL); set_end_time(); time_thread=end_time-start_time; printf("As threads foram finalizadas.\n\n"); check_matrix_match(matrix_copy); printf("\n"); printf("Tempo na main(): %f segundos\n",time_main); printf("Tempo com threads: %f segundos\n",time_thread); //Libera tudo que foi alocado. free(thread_vector); free(offset_vector); for(counter=0; counter<matrix_size; counter++) { free(matrix_a[counter]); free(matrix_b[counter]); free(matrix_result[counter]); free(matrix_copy[counter]); } free(matrix_a); free(matrix_b); free(matrix_result); free(matrix_copy); return 0; }