int main(){ // generate an appropriate test input printf("Lets find some good floats to run our tests against!\n"); fertile_valley fv = FarmEscapers(100000, 500, 150000); printf("Gee golly, %p is a good place to sow wild floats. \n", &fv); // execute one recurrence per loop printf("Running loop with one iteration going on per loop.\n"); time_start(); SinglyExecuteRecurrence(&fv); time_end(); // execute two recurrences per loop printf("Running loop with two iterations going on per loop\n"); time_start(); DoubleExecuteRecurrence(&fv); time_end(); // execute three recurrences per loop printf("Running loop with three iterations going on per loop\n"); time_start(); TriplyExecuteRecurrence(&fv); time_end(); // execute three recurrences per loop printf("Running loop with four iteration going on per loop\n"); time_start(); TriplyExecuteRecurrence(&fv); time_end(); return 0; }
void run_stats_update(struct cgp_t *cgp, struct run_stats_t *stats) { fitness_t f; cgp_walk_popul(cgp, &find_best_fitness, &f); stats->gener += 1; if(stats->start_gener == 0) { time_start(&stats->start); stats->start_gener = stats->gener; } else if(ms_elapsed(&stats->start) > 250) { long speed = 4 * (stats->gener - stats->start_gener); time_start(&stats->start); stats->start_gener = stats->gener; fprintf(stderr, "\rBest fitness (%6.zu, %6.ld/s): %6.zu", stats->gener, speed, f); } if(!stats->has_acceptable) { if(fitness_isacceptable(f)) { stats->has_acceptable = 1; fprintf(stderr, "\nHas acceptable result %zu, now optimizing...\n", f); } } }
void testCombinaisonEstNombreArmstrong_Executer371() { puts("Debut testCombinaisonEstNombreArmstrong_Executer371"); CachePuissance10 *cachePuissance10; cachePuissance10 = InitCachePuissance10(19); CachePuissanceDigit *cachePuissanceDigit; cachePuissanceDigit = InitCachePuissanceDigit(1, 19); char combinaison[3] = {1, 7, 3}; char combinaison2[19] = {3,2,8,9,5,8,2,9,8,4,4,4,3,1,8,7,0,3,2}; char combinaison3[2] = {3,2}; TacheCombinaisonEstNombreArmstrong *tache1, *tache2, *tache3; tache1 = TacheCombinaisonEstNombreArmstrong_Init(3, 300, 1000, cachePuissanceDigit, cachePuissance10); tache2 = TacheCombinaisonEstNombreArmstrong_Init(19, 1, 4000000000000000000LL, cachePuissanceDigit, cachePuissance10); tache3 = TacheCombinaisonEstNombreArmstrong_Init(2, 31, 34, cachePuissanceDigit, cachePuissance10); long long test_time; // Test1 TacheCombinaisonEstNombreArmstrong_SetCombinaison(tache1, combinaison); test_time = time_start(); TacheCombinaisonEstNombreArmstrong_Executer(tache1); printf("T: 371 : %lld\n", time_end(test_time)); assert(tache1 -> resultat == 371); // Test2 TacheCombinaisonEstNombreArmstrong_SetCombinaison(tache2, combinaison2); test_time = time_start(); TacheCombinaisonEstNombreArmstrong_Executer(tache2); //printf("D: tache2 -> result %lld\n", tache2 -> resultat); printf("T: 3289582984443187032 : %lld\n", time_end(test_time)); assert(tache2 -> resultat == 3289582984443187032LLU); // Test3 TacheCombinaisonEstNombreArmstrong_SetCombinaison(tache3, combinaison3); test_time = time_start(); TacheCombinaisonEstNombreArmstrong_Executer(tache3); printf("T: 23 : %lld\n", time_end(test_time)); assert(tache3 -> resultat == -1); TacheCombinaisonEstNombreArmstrong_Detruire(tache1); TacheCombinaisonEstNombreArmstrong_Detruire(tache2); TacheCombinaisonEstNombreArmstrong_Detruire(tache3); }
//int main(int argc, char *argv[]) int main() { time_start(); { mthread_t thread1, thread2; void *retval1, *retval2; int err; printf("le main lance 2 threads...\n"); err = mthread_create(&thread1, threadfunc, "thread1"); assert(!err); err = mthread_create(&thread2, threadfunc, "thread2"); assert(!err); printf("le main a lancé les threads %p et %p\n", thread1, thread2); printf("le main attend les threads\n"); err = mthread_join(thread2, &retval2); assert(!err); err = mthread_join(thread1, &retval1); assert(!err); printf("les threads ont terminé en renvoyant '%s' and '%s'\n", (char *) retval1, (char *) retval2); } time_end() ; return 0; }
void testPuissance10Clone() { puts("L: Debut du test testPuissance10Exposant5"); CachePuissance10 *cachePuissance10Exposant5, *cloneCache; cachePuissance10Exposant5 = InitCachePuissance10(5); long long test_time; test_time= time_start(); cloneCache = CloneCachePuissance10(cachePuissance10Exposant5); // Tests assert(cloneCache -> cache != cachePuissance10Exposant5 -> cache); assert(GetPuissance10(cloneCache,0) == 1); assert(GetPuissance10(cloneCache,1) == 10); assert(GetPuissance10(cloneCache,5) == 100000); DetruireCachePuissance10(cloneCache); DetruireCachePuissance10(cachePuissance10Exposant5); printf("T: %lld\n", time_end(test_time)); puts("L: Fin du test testPuissance10Exposant5"); puts(""); }
int simulation_init() { simulation_cleanup(); initialize_cells(); simulation.update = simulation.generations = 1; simulation.g_pred_breed = 15; simulation.g_pred_starve = 5; simulation.g_prey_breed = 5; if(Application->r_w % MAP_WIDTH != 0 || Application->r_h % MAP_HEIGHT != 0) { MessageBox(Application->hWnd, "Width or height do not divide evenly into resolution.\n", "Attention", MB_ICONEXCLAMATION); } simulation.gwidth = floor(Application->r_w / MAP_WIDTH); simulation.gheight = floor(Application->r_h / MAP_HEIGHT); init_dialog(); if(!simulation.Config) { fprintf(stderr, "Configuration dialog failed to load. GetLastError: %s \n", (char*)GetLastError()); return 0; } setStatus("Varibles set up successfully."); time_start(Gametimer); time_pause(Gametimer); simulation.generation = simulation.tickdelay = simulation.total_prey = simulation.total_pred = amount = 0; cleanup_cells(); return 1; }
void testPuissanceDigitClone() { puts("L: Debut du test testPuissanceDigitClone"); CachePuissanceDigit *cachePuissanceDigitExposant5, *cloneCache; cachePuissanceDigitExposant5 = InitCachePuissanceDigit(0, 20); long long test_time; test_time= time_start(); cloneCache = CloneCachePuissanceDigit(cachePuissanceDigitExposant5); // Tests assert(cloneCache -> cache != cachePuissanceDigitExposant5 -> cache); assert(GetPuissanceDigit(cachePuissanceDigitExposant5, 4, 3) == 64); assert(GetPuissanceDigit(cachePuissanceDigitExposant5, 0, 3) == 0); assert(GetPuissanceDigit(cachePuissanceDigitExposant5, 0, 5) == 0); DetruireCachePuissanceDigit(cloneCache); DetruireCachePuissanceDigit(cachePuissanceDigitExposant5); printf("T: %lld\n", time_end(test_time)); puts("L: Fin du test testPuissanceDigitClone"); puts(""); }
/* Returns second per function call */ static double time_function(void (*f)(void *arg), void *arg) { unsigned ncalls; double elapsed; /* Warm up */ f(arg); for (ncalls = 10 ;;) { unsigned i; time_start(); for (i = 0; i < ncalls; i++) f(arg); elapsed = time_end(); if (elapsed > BENCH_INTERVAL) break; else if (elapsed < BENCH_INTERVAL / 10) ncalls *= 10; else ncalls *= 2; } return elapsed / ncalls; }
/// <summary> /// шейкерная сортировка /// </summary> void Sol2() { int a[MaxN]; // создаём массив максимального размера int i = 0; int min = 0; int max = 0; int counter = 0; // заполняем его произвольными значениями for (i=0; i < MaxN; i++) { a[i] = rand(); } puts("Массив до сортировки"); //print(MaxN, a); // сделаем копию, для более точной оценки результатов // for (i = 0; i < MaxN; i++) b[i] = a[i]; time_start(); // непосредствено алгоритм // проходим в одну сторону, сортируя все позиции // потом в обратную, уменьшая при этом правую и левую границу на -1 // повторяем до отсутствия свапов в отсторитрованном массиве max = MaxN; min = 0; bool sorted = false; while (!sorted) { for (i = min; i < max - 1; i++) { sorted = true; if (a[i] > a[i + 1]) { swap(&a[i], &a[i + 1]); sorted = false; } counter++; } max--; for (i = max; i > min; i--) { if (a[i] < a[i - 1]) { swap(&a[i], &a[i - 1]); } counter++; } min++; } double time_elapsed = time_stop(); puts("Массив после сортиорвки"); //print(MaxN, a); puts("\nСортировка заняла: "); printf("%7.2lf\n", time_elapsed); puts("Количество операций совершено: "); printf("%d\n", counter); }
void game_time_initialize(void) { time_start(); game_tick=0; game_last_tick=time_get(); server.time.paused=FALSE; }
void testCombinaisonEstNombreArmstrong_Clone() { puts("Debut testCombinaisonEstNombreArmstrong_Clone"); char combinaison[3] = {1, 2, 3}; char combinaison2[3] = {1, 2, 4}; TacheCombinaisonEstNombreArmstrong *tache1, *tache2; CachePuissance10 * cachePuissance10; cachePuissance10 = InitCachePuissance10(5); CachePuissanceDigit *cachePuissanceDigit; cachePuissanceDigit = InitCachePuissanceDigit(1, 5); long long test_time_init; test_time_init = time_start(); tache1 = TacheCombinaisonEstNombreArmstrong_Init(3, 200, 400, cachePuissanceDigit, cachePuissance10); TacheCombinaisonEstNombreArmstrong_SetCombinaison(tache1, combinaison); printf("T: Init : %lld\n", time_end(test_time_init)); long long test_time_clone; test_time_clone= time_start(); tache2 = TacheCombinaisonEstNombreArmstrong_Clone(tache1); TacheCombinaisonEstNombreArmstrong_SetCombinaison(tache2, combinaison2); printf("T: Clone : %lld\n", time_end(test_time_clone)); assert((tache1 -> combinaison)[1] == 2); assert((tache1 -> combinaison)[2] == 3); assert((tache1 -> combinaison)[1] == 2); assert((tache2 -> combinaison)[2] == 4); TacheCombinaisonEstNombreArmstrong_Detruire(tache1); TacheCombinaisonEstNombreArmstrong_Detruire(tache2); puts("Fin testCombinaisonEstNombreArmstrong_Clone"); puts(""); }
static void timed_buffer_unmap(struct pipe_winsys *winsys, struct pipe_buffer *buf) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); backend->buffer_unmap( backend, buf ); time_finish(winsys, start, 3, __FUNCTION__); }
int main(int argc, char *argv[]) { double t, mypi; time_start(); mypi = pi_calculate(1000000000); t = time_stop(); printf("Time: %lf sec Pi = %14.12lf\n",t,mypi); return 0; }
static void timed_buffer_destroy(struct pipe_buffer *buf) { struct pipe_winsys *winsys = buf->screen->winsys; struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); backend->buffer_destroy( buf ); time_finish(winsys, start, 4, __FUNCTION__); }
static void timed_fence_reference(struct pipe_winsys *winsys, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); backend->fence_reference( backend, ptr, fence ); time_finish(winsys, start, 10, __FUNCTION__); }
static const char * timed_get_name( struct pipe_winsys *winsys ) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); const char *ret = backend->get_name( backend ); time_finish(winsys, start, 9, __FUNCTION__); return ret; }
static void timed_flush_frontbuffer( struct pipe_winsys *winsys, struct pipe_surface *surf, void *context_private) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); backend->flush_frontbuffer( backend, surf, context_private ); time_finish(winsys, start, 5, __FUNCTION__); }
int uas_start(sipua_uas_t *sipuas) { eXosipua_t *jua = (eXosipua_t*)sipuas; jua->clock = time_start(); jua->thread = xthr_new(jua_loop, jua, XTHREAD_NONEFLAGS); if(jua->thread == NULL) return UA_FAIL; return UA_OK; }
void time_main_test(void) { int i; time_start(); for(i=0; i<FUNC_EXEC_TIME; i++) //timt_test(); time_stop(); time_print(); }
static void * timed_buffer_map(struct pipe_winsys *winsys, struct pipe_buffer *buf, unsigned flags) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); void *map = backend->buffer_map( backend, buf, flags ); time_finish(winsys, start, 2, __FUNCTION__); return map; }
static struct pipe_buffer * timed_user_buffer_create(struct pipe_winsys *winsys, void *data, unsigned bytes) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); struct pipe_buffer *buf = backend->user_buffer_create( backend, data, bytes ); time_finish(winsys, start, 1, __FUNCTION__); return buf; }
static int timed_fence_finish( struct pipe_winsys *winsys, struct pipe_fence_handle *fence, unsigned flag ) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); int ret = backend->fence_finish( backend, fence, flag ); time_finish(winsys, start, 12, __FUNCTION__); return ret; }
void model_play(int play_mode) { int n,tick,pose_move_idx; // good animation? if (play_mode!=model_play_mode_stop) { if (state.model.cur_animate_idx==-1) return; if (model.animates[state.model.cur_animate_idx].npose_move==0) return; } // always turn off animation until setup is complete // as animation is on a timer state.model.play_mode=model_play_mode_stop; // if it's next or previous, we // need to start on current selection pose_move_idx=0; switch (play_mode) { case model_play_mode_prev: pose_move_idx=state.model.cur_animate_pose_move_idx-1; if (pose_move_idx<0) pose_move_idx=model.animates[state.model.cur_animate_idx].npose_move-1; break; case model_play_mode_next: pose_move_idx=state.model.cur_animate_pose_move_idx; break; } // setup animation time_start(); tick=time_get(); for (n=0;n!=max_model_blend_animation;n++) { state.model.blend[n].pose_move_idx=pose_move_idx; state.model.blend[n].tick=tick; } // turn on/off animation state.model.play_mode=play_mode; if (state.model.model_open) main_wind_draw(); }
/* Pipe has no concept of pools, but the psb driver passes a flag that * can be mapped onto pools in the backend. */ static struct pipe_buffer * timed_buffer_create(struct pipe_winsys *winsys, unsigned alignment, unsigned usage, unsigned size ) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); struct pipe_buffer *buf = backend->buffer_create( backend, alignment, usage, size ); time_finish(winsys, start, 0, __FUNCTION__); return buf; }
static struct pipe_buffer * timed_surface_buffer_create(struct pipe_winsys *winsys, unsigned width, unsigned height, enum pipe_format format, unsigned usage, unsigned *stride) { struct pipe_winsys *backend = timed_winsys(winsys)->backend; uint64_t start = time_start(); struct pipe_buffer *ret = backend->surface_buffer_create( backend, width, height, format, usage, stride ); time_finish(winsys, start, 7, __FUNCTION__); return ret; }
// Fonctions int main(int argc, char* argv[]) { unsigned int n = 10, i; struct indices indice; // Arg Filter if (argc > 1) n = atoi(argv[1]); if (argc > 2) affiche_tableau = 1; if (argc > 3) affiche_arg = 1; if (n<1) { printf("Veuillez entrer un entier positif.\n"); return 0; } // on crée le tableau tableau = malloc (n*sizeof(unsigned long int)); printf("\tn = %u\n", n); if (affiche_tableau) printf("tab :"); // on l'initialise for ( i=0 ; i<n ; i++) { tableau[i] = i; if (affiche_tableau) printf(" %lu", tableau[i]); } if (affiche_tableau) printf("\n"); indice.a = 0; indice.b = n-1; time_start(); { tab_sum((void*) &indice); if (affiche_arg) printf("\n"); printf("\tLa somme des éléments du tableau est égale à : %lu\n", tableau[0]); } time_end(); return EXIT_SUCCESS; }
int execute(int argc, char** argv) { boost::posix_time::ptime time_start(boost::posix_time::second_clock::local_time()); INFO(_name << " - started at " << time_start); DEBUG("Source code version: " APPLICATION_SOURCE_VERSION); DEBUG("Compiled on: " __DATE__ " - " __TIME__); int result= EXIT_SUCCESS; try { DEBUG("Parsing program parameters..."); // Parse options po::variables_map vm; po::options_description desc= get_named_options(); po::positional_options_description p= get_positional_options(); po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); po::notify(vm); DEBUG("Program parameters successfully parsed."); // Execute DEBUG("Beginning execution..."); result= execution(argc, argv, vm); DEBUG("Execution successfully completed."); } catch (std::exception& e) { FATAL("EXCEPTION OCCURRED: " << e.what()); result= EXIT_FAILURE; } catch (assertion_failed_exception& e) { FATAL("ASSERTION FAILED: " << e.what()); result= EXIT_FAILURE; throw e; } catch (...) { FATAL("GENERIC EXCEPTION OCCURRED."); result= EXIT_FAILURE; } boost::posix_time::ptime time_end(boost::posix_time::second_clock::local_time()); INFO("Running time: " << (time_end-time_start)); INFO(_name << " - terminated at " << time_end); return result; }
void worker::run () { try { assert(_context != NULL); assert(_connectAddr.c_str() != NULL); fprintf(stdout, "worker: connect address: %s\n", _connectAddr.c_str()); fprintf(stdout, "worker: stop requested: %d\n", _stopRequested); zmq::socket_t subscriber(*_context, ZMQ_SUB); subscriber.connect(_connectAddr.c_str()); const char* filter = ""; subscriber.setsockopt(ZMQ_SUBSCRIBE, filter, strlen(filter)); //capkproto::instrument_bbo bbo; _inproc = new zmq::socket_t(*_context, ZMQ_PUB); assert(_inproc); _inproc->connect(_inprocAddr.c_str()); zmq::message_t msg; while (1 && _stopRequested == false) { subscriber.recv(&msg); #ifdef DEBUG boost::posix_time::ptime time_start(boost::posix_time::microsec_clock::local_time()); #endif int64_t more; size_t more_size; more_size = sizeof(more); subscriber.getsockopt(ZMQ_RCVMORE, &more, &more_size); // send to orderbook on inproc socket - no locks needed according to zmq _inproc->send(msg, more ? ZMQ_SNDMORE : 0); #ifdef DEBUG boost::posix_time::ptime time_end(boost::posix_time::microsec_clock::local_time()); boost::posix_time::time_duration duration(time_end - time_start); fprintf(stderr, "Inbound from md interface time to receive and parse: %s\n", to_simple_string(duration).c_str()); #endif } } catch (std::exception& e) { std::cerr << "EXCEPTION: " << __FILE__ << __LINE__ << e.what(); } }
int main(int argc, char** argv) { // Sizing questions std::cerr << "sizeof(order_id_t): " << sizeof(order_id_t) << std::endl; std::cerr << "sizeof(strategy_id_t): " << sizeof(strategy_id_t) << std::endl; std::cerr << "sizeof(mc): " << sizeof(mc) << std::endl; std::cerr << "sizeof(OrderInfo): " << sizeof(OrderInfo) << std::endl; std::cerr << "sizeof(OrderInfo_ptr): " << sizeof(OrderInfo_ptr) << std::endl; boost::posix_time::ptime time_start(boost::posix_time::microsec_clock::local_time()); testing::InitGoogleTest(&argc, argv); int result = RUN_ALL_TESTS(); boost::posix_time::ptime time_end(boost::posix_time::microsec_clock::local_time()); boost::posix_time::time_duration duration(time_end - time_start); std::cout << "Duration: " << duration << std::endl; return result; }
void testCalculArmstrong() { char Combinaison[19] = {4,4,9,8,1,2,8,7,9,1,1,6,4,4,2,4,8,6,9}; CachePuissanceDigit *cachePuissanceDigitExposant19; cachePuissanceDigitExposant19 = InitCachePuissanceDigit(0, 19); CachePuissance10 * cachePuissance10Exposant; cachePuissance10Exposant = InitCachePuissance10(19); // Tests long long test_time; test_time = time_start(); puts("L: Debut du test"); assert(CalculNombreArmstrong(Combinaison,19, cachePuissanceDigitExposant19) == 4498128791164624869ULL); assert(EstUnNombreArmstrong(Combinaison,CalculNombreArmstrong(Combinaison,19,cachePuissanceDigitExposant19),19, cachePuissance10Exposant) == TRUE); printf("%lld us\n",time_end(test_time)); puts("L: Fin du test"); puts(""); }