void eat(void) { short ch; short moves; object *obj; char buf[70]; ch = pack_letter(mesg[262], FOOD); if (ch == CANCEL) { return; } if (!(obj = get_letter_object(ch))) { message(mesg[263], 0); return; } if (obj->what_is != FOOD) { message(mesg[264], 0); return; } if ((obj->which_kind == FRUIT) || rand_percent(60)) { moves = get_rand(900, 1100); if (obj->which_kind == RATION) { if (get_rand(1, 10) == 1) { message(mesg[265], 0); } else message(mesg[266], 0); } else { sprintf(buf, mesg[267], fruit); message(buf, 0); } } else { moves = get_rand(700, 900); message(mesg[268], 0); add_exp(2, 1); } rogue.moves_left /= 3; rogue.moves_left += moves; hunger_str[0] = 0; print_stats(STAT_HUNGER); vanish(obj, 1, &rogue.pack); }
void ThreadLocalAllocBuffer::accumulate_statistics() { Thread* thread = myThread(); size_t capacity = Universe::heap()->tlab_capacity(thread); size_t used = Universe::heap()->tlab_used(thread); _gc_waste += (unsigned)remaining(); size_t total_allocated = thread->allocated_bytes(); size_t allocated_since_last_gc = total_allocated - _allocated_before_last_gc; _allocated_before_last_gc = total_allocated; if (PrintTLAB && (_number_of_refills > 0 || Verbose)) { print_stats("gc"); } if (_number_of_refills > 0) { // Update allocation history if a reasonable amount of eden was allocated. bool update_allocation_history = used > 0.5 * capacity; if (update_allocation_history) { // Average the fraction of eden allocated in a tlab by this // thread for use in the next resize operation. // _gc_waste is not subtracted because it's included in // "used". // The result can be larger than 1.0 due to direct to old allocations. // These allocations should ideally not be counted but since it is not possible // to filter them out here we just cap the fraction to be at most 1.0. double alloc_frac = MIN2(1.0, (double) allocated_since_last_gc / used); _allocation_fraction.sample(alloc_frac); } global_stats()->update_allocating_threads(); global_stats()->update_number_of_refills(_number_of_refills); global_stats()->update_allocation(_number_of_refills * desired_size()); global_stats()->update_gc_waste(_gc_waste); global_stats()->update_slow_refill_waste(_slow_refill_waste); global_stats()->update_fast_refill_waste(_fast_refill_waste); } else { assert(_number_of_refills == 0 && _fast_refill_waste == 0 && _slow_refill_waste == 0 && _gc_waste == 0, "tlab stats == 0"); } global_stats()->update_slow_allocations(_slow_allocations); }
// Signal handler // HUP print the stats // INT end server // TERM end server void intHandler(int signum) { log_msg(daemon_mode, "Signal %s (%d) receieved", strsignal(signum), signum); switch(signum) { case SIGINT: running = 0; break; case SIGTERM: running = 0; break; case SIGHUP: loadRobots(jailDir); loadSitemap(jailDir); time(&finish); printTZ(); print_stats(daemon_mode, start, finish, "running for"); break; default: break; } }
static int read_chunk(struct rucb_conn *c, int offset, char *to, int maxsize) { int size; size = maxsize; if(bytecount + maxsize >= FILESIZE) { size = FILESIZE - bytecount; } bytecount += size; if(bytecount == FILESIZE) { printf("Completion time %lu / %u\n", (unsigned long)clock_time() - start_time, CLOCK_SECOND); /* profile_aggregates_print(); */ /* profile_print_stats(); */ print_stats(); } /* printf("bytecount %lu\n", bytecount);*/ return size; }
/** * This function loops through the level and does N iterations of * the stat calling function, assuming diving style. */ static void diving_stats(void) { int depth; /* Iterate through levels */ for (depth = 0; depth < MAX_LVL; depth += 5) { player->depth = depth; if (player->depth == 0) player->depth = 1; /* Do many iterations of each level */ for (iter = 0; iter < tries; iter++) stats_collect_level(); /* Print the output to the file */ print_stats(depth); /* Show the level to check on status */ do_cmd_redraw(); } }
static void msg_add(struct msg *msg) { unsigned int timeout = TX_TIMEOUT; struct timespec abstime; int error; assert(!msg->next); pthread_mutex_lock(&list_mutex); if (list_size > MAX_LIST_SIZE) { pr_debug("Too many bytes in flight, pausing...\n"); if (clock_gettime(CLOCK_REALTIME, &abstime)) { pr_error("Failed to get clock: %s\n", strerror(errno)); exit(-1); } abstime.tv_sec += timeout; do { error = pthread_cond_timedwait(&list_full, &list_mutex, &abstime); if (error == ETIMEDOUT) { pr_error("Timeout, aborting\n"); print_stats(); exit(-1); } } while (list_size > MAX_LIST_SIZE); } if (list_tail) list_tail->next = msg; else list_head = msg; list_tail = msg; list_size++; pthread_mutex_unlock(&list_mutex); pthread_cond_signal(&list_nonempty); }
void eat(void) { short ch; short moves; object *obj; char buf[70]; ch = pack_letter("eat what?", FOOD); if (ch == CANCEL) { return; } if (!(obj = get_letter_object(ch))) { message("no such item.", 0); return; } if (obj->what_is != FOOD) { message("you can't eat that", 0); return; } if ((obj->which_kind == FRUIT) || rand_percent(60)) { moves = get_rand(950, 1150); if (obj->which_kind == RATION) { message("yum, that tasted good", 0); } else { sprintf(buf, "my, that was a yummy %s", fruit); message(buf, 0); } } else { moves = get_rand(750, 950); message("yuk, that food tasted awful", 0); add_exp(2, 1); } rogue.moves_left /= 3; rogue.moves_left += moves; hunger_str[0] = 0; print_stats(STAT_HUNGER); vanish(obj, 1, &rogue.pack); }
void ThreadLocalAllocBuffer::accumulate_statistics() { size_t capacity = Universe::heap()->tlab_capacity(myThread()) / HeapWordSize; size_t unused = Universe::heap()->unsafe_max_tlab_alloc(myThread()) / HeapWordSize; size_t used = capacity - unused; // Update allocation history if a reasonable amount of eden was allocated. bool update_allocation_history = used > 0.5 * capacity; _gc_waste += (unsigned)remaining(); if (PrintTLAB && (_number_of_refills > 0 || Verbose)) { print_stats("gc"); } if (_number_of_refills > 0) { if (update_allocation_history) { // Average the fraction of eden allocated in a tlab by this // thread for use in the next resize operation. // _gc_waste is not subtracted because it's included in // "used". size_t allocation = _number_of_refills * desired_size(); double alloc_frac = allocation / (double) used; _allocation_fraction.sample(alloc_frac); } global_stats()->update_allocating_threads(); global_stats()->update_number_of_refills(_number_of_refills); global_stats()->update_allocation(_number_of_refills * desired_size()); global_stats()->update_gc_waste(_gc_waste); global_stats()->update_slow_refill_waste(_slow_refill_waste); global_stats()->update_fast_refill_waste(_fast_refill_waste); } else { assert(_number_of_refills == 0 && _fast_refill_waste == 0 && _slow_refill_waste == 0 && _gc_waste == 0, "tlab stats == 0"); } global_stats()->update_slow_allocations(_slow_allocations); }
int famstats_fm_main(int argc, char *argv[]) { famstats_t *s; int c; famstats_fm_settings_t settings{0}; settings.notification_interval = 1000000; while ((c = getopt(argc, argv, "m:f:n:Fh?")) >= 0) { switch (c) { case 'm': settings.minmq = atoi(optarg); break; break; case 'f': settings.minFM = atoi(optarg); break; break; case 'F': settings.skip_fp_fail = 1; break; case 'n': settings.notification_interval = strtoull(optarg, nullptr, 0); break; case '?': case 'h': return famstats_fm_usage(EXIT_SUCCESS); } } if (argc != optind+1) { return famstats_fm_usage((argc == optind) ? EXIT_SUCCESS: EXIT_FAILURE); } LOG_INFO("Running famstats fm with minmq %i and minFM %i.\n", settings.minmq, settings.minFM); for(const char *tag: tags_to_check) dlib::check_bam_tag_exit(argv[optind], tag); dlib::BamHandle handle(argv[optind]); s = famstats_fm_core(handle, &settings); print_stats(s, stdout, &settings); kh_destroy(fm, s->fm); kh_destroy(fm, s->np); kh_destroy(fm, s->rc); free(s); LOG_INFO("Successfully completed bmftools famstats fm.\n"); return EXIT_SUCCESS; }
void sting(object *monster) { short sting_chance = 35; char msg[80]; if ((rogue.str_current <= 3) || sustain_strength) { return; } sting_chance += (6 * (6 - get_armor_class(rogue.armor))); if ((rogue.exp + ring_exp) > 8) { sting_chance -= (6 * ((rogue.exp + ring_exp) - 8)); } if (rand_percent(sting_chance)) { sprintf(msg, mesg[207], mon_name(monster)); message(msg, 0); rogue.str_current--; print_stats(STAT_STRENGTH); } }
int main() { test_t *tests[TEST_COUNT] = { test(test_parse_reg), test(test_parse_reg_without_args), test(test_parse_error), test(test_parse_exit), test(test_parse_exit_with_line_feed), test(test_parse_exit_with_line_ending), test(test_parse_pwd), }; for (int i = 0; i < TEST_COUNT && tests[i] != NULL; ++i) { test_t *t = tests[i]; t->t(t); eval(t); } print_stats(tests, TEST_COUNT); return 0; }
int static fifo_stats( FILE *pipe, char *response_file ) { FILE *file; if (response_file==0 || *response_file==0 ) { LOG(L_ERR, "ERROR: fifo_stats: null file\n"); return -1; } file=open_reply_pipe(response_file ); if (file==NULL) { LOG(L_ERR, "ERROR: fifo_stats: file %s bad: %s\n", response_file, strerror(errno) ); return -1; } fputs( "200 ok\n", file); print_stats( file ); fclose(file); return 1; }
~stats (void) { if (this->quantify_) { #if defined (USING_QUANTIFY) // Stop recording data here; whatever happens after this is // not relevant. QuantifyStopRecordingData (); #endif /* USING_QUANTIFY */ } // stop the timer. this->timer_.stop (); ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; this->timer_.elapsed_time (elapsed_time); // compute average time. ACE_DEBUG ((LM_DEBUG, "\n%C stats...\n", this->test_name_)); print_stats (elapsed_time); }
static void do_output(int test_type, long long *array, int bins, int show_std_dev, int show_dist) { int s[10]; long long min, max; double average, std; std = do_stats(array, &min, &max, &average); print_stats(test_type, min, max, average, std); if (show_std_dev) { do_std_dev(array, s, std, average); print_std_dev(s); } if (show_dist) { int *d; d = malloc(bins*sizeof(int)); do_dist(array, min, max, bins, d); print_dist(min, max, bins, d); free(d); } }
int main(int argc, char** argv) { /* * argv[1] = first run's directory * argv[2] = second run's directory */ if (argc != 4) { DEBUG(stderr, "argv[1] = first run's directory, argv[2] = second run's directory, argv[3] = input file\n"); } assert(argc == 4); DEBUG(stderr, "argv0 = %s, argv1 = %s, argv2 = %s \n", argv[0], argv[1], argv[2]); first_dir = (struct directory_files*) malloc(sizeof(struct directory_files)); second_dir = (struct directory_files*) malloc(sizeof(struct directory_files)); gettimeofday(&stats.start, NULL); DEBUG(stderr, "init_filename\n"); if (!init_filenames(argv[1], argv[2], argv[3])) { fprintf(stderr, "init filenames failed\n"); exit(1); } DEBUG(stderr, "build_address_lookup\n"); if (!build_address_lookup(first_dir->snapshot, second_dir->snapshot)) { fprintf(stderr, "build_dictionary failed\n"); exit(1); } build_tables(first_dir, second_dir); // init_get_input_addrs(second_dir->dataflow_result); process_outputs(argv[3]); save_outputs(); gettimeofday(&stats.end, NULL); print_stats(stats); return 1; }
/* Powers down the machine we're running on, as long as we're running on Bochs or QEMU. */ void shutdown_power_off (void) { switch (shutdown_power_off_recursion ++) { case 0: #ifdef FILESYS { enum intr_level old_level = intr_enable (); filesys_done (); intr_set_level (old_level); } #endif case 1: print_stats (); printf ("Powering off...\n"); serial_flush (); break; default: shutdown_power_off_recursion = 2; } for (;;) { /* This is a special power-off sequence supported by Bochs and QEMU, but not by physical hardware. */ const char *p; for (p = "Shutdown"; *p; ++p) outb (0x8900, *p); /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE" is set in its configuration file. (The "pintos" script does that automatically.) */ asm volatile ("cli; hlt"); printf ("still running...\n"); } }
static void run (CORBA::ORB_ptr orb, ACE_TCHAR *IOR) { if (IOR != 0) { // Get an object reference from the argument string. CORBA::Object_var object = orb->string_to_object (IOR); // Try to narrow the object reference to a reference. T_var test = T::_narrow (object.in ()); ACE_Profile_Timer timer; ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; // We start an ACE_Profile_Timer here... timer.start (); CORBA::Long result = 0; int i = 0; for (i = 0; i < iterations ; i++) { // Invoke the doit() method on the reference. result = test->doit (); } // stop the timer. timer.stop (); timer.elapsed_time (elapsed_time); // compute average time. print_stats (elapsed_time, i); // Print the result of doit () method on the reference. ACE_DEBUG ((LM_DEBUG, "%d\n", result)); } }
int wrap_up P1H(void){ #line 1152 "./cwebdir/common.w" putchar('\n'); if(show_stats) print_stats(); /*64:*/ #line 1160 "./cwebdir/common.w" switch(history){ case spotless:if(show_happiness)printf("(No errors were found.)\n");break; case harmless_message: printf("(Did you see the warning message above?)\n");break; case error_message: printf("(Pardon me, but I think I spotted something wrong.)\n");break; case fatal_message:printf("(That was a fatal error, my friend.)\n"); } /*:64*/ #line 1155 "./cwebdir/common.w" ; if(history> harmless_message)return(1); else return(0); }
static void prefs_form_save_prefs(Short rw, Short ws) { Boolean dirty, verydirty; dirty = prefs_save_lists(rw, ws); verydirty = prefs_save_checkboxes_1(); dirty = prefs_save_checkboxes_2() || dirty; writePrefs(); LeaveForm(); if (verydirty) { // clear-and-redraw absolutely everything clear_visible(); move_visible_window(you.ux, you.uy, true); show_messages(); refresh(); flags.botl = BOTL_ALL; print_stats(0); } else if (dirty) { // don't need to redraw msgs or stats // ? move_visible_window(you.ux, you.uy, true); refresh(); } }
int close_streamer(struct opt_s *opt) { D("Closing streamer"); struct stats *stats_full = (struct stats *)malloc(sizeof(struct stats)); init_stats(stats_full); D("stats ready"); if (opt->streamer_ent != NULL) opt->streamer_ent->close(opt->streamer_ent, (void *)stats_full); D("Closed streamer_ent"); #if(!DAEMON) close_rbufs(opt, stats_full); close_recp(opt, stats_full); D("Membranch and diskbranch shut down"); #else stats_full->total_written = opt->bytes_exchanged; #endif D("Printing stats"); print_stats(stats_full, opt); free(stats_full); D("Stats over"); return 0; }
int main (int argc, char **argv) { char *cmd; char *fname; if (argc < 3) { usage(); return 0; } argv++; cmd = *(argv++); fname = *(argv++); switch (*cmd) { case 'c': // create if (mw_create(fname, argv, argc)) { usage(); } break; case 's': // stats print_stats(fname); break; case 'f': // fetch get_data(fname, argv); break; case 'd': // dump dump_data(fname, argv); break; case 'u': // update update_meta(fname, argv); break; default: printf("Error: Unrecognized command: %s\n", cmd); } return 0; }
/* Powers down the machine we're running on, as long as we're running on Bochs or QEMU. */ void shutdown_power_off (void) { const char s[] = "Shutdown"; const char *p; #ifdef FILESYS printf("Closing filesystem\n"); filesys_done (); printf("Printing Files in root directory\n"); void * LIST; fsutil_ls(LIST); printf("Printed Files in root directory\n"); printf("Setting *inode NULL\n"); printf("Closed filesystem\n"); #endif print_stats (); printf ("Powering off...\n"); serial_flush (); /* This is a special power-off sequence supported by Bochs and QEMU, but not by physical hardware. */ for (p = s; *p != '\0'; p++) outb (0x8900, *p); /* This will power off a VMware VM if "gui.exitOnCLIHLT = TRUE" is set in its configuration file. (The "pintos" script does that automatically.) */ asm volatile ("cli; hlt" : : : "memory"); /* None of those worked. */ printf ("still running...\n"); for (;;); }
int main() { int argc; char **argv; win32_get_argv_utf8(&argc, &argv); #else int main(int argc, char **argv) { #endif parse_shift_args(&opts, &argc, &argv); __idris_argc = argc; __idris_argv = argv; VM* vm = init_vm(opts.max_stack_size, opts.init_heap_size, 1); init_threadkeys(); init_threaddata(vm); init_gmpalloc(); init_nullaries(); init_signals(); _idris__123_runMain0_125_(vm, NULL); #ifdef IDRIS_DEBUG if (opts.show_summary) { idris_gcInfo(vm, 1); } #endif Stats stats = terminate(vm); if (opts.show_summary) { print_stats(&stats); } free_nullaries(); return EXIT_SUCCESS; }
void acc_prv_decrypt_done(SshCryptoStatus status, const unsigned char *data, size_t length, void *context) { SshExternalKeyTestCtx ctx = context; ctx->accelerated_encrypts_pending--; ctx->operations_done++; if (status == SSH_CRYPTO_OK) { SSH_DEBUG(2, ("Completed private key decrypt succesfully.\n" "Left: %d\n" "Pending: %d", ctx->accelerated_encrypts_left, ctx->accelerated_encrypts_pending)); } else { SSH_DEBUG(1, ("Decrypt failed.")); ctx->operations_failed++; } if (!continuous_test && ctx->accelerated_encrypts_left == 0 && ctx->accelerated_encrypts_pending == 0) { SshUInt64 secs; SshUInt32 nanos; SshUInt32 s; ssh_time_measure_get_value(ctx->timer, &secs, &nanos); s = (SshUInt32)secs; SSH_DEBUG(1, ("Private key test completed in %ds and %dns", s, nanos)); print_stats(ctx); exit(0); } }
static void do_import(int argc, char **argv) { srld_db db; FILE *fp; #define BUFSZ 1024*32 char json[BUFSZ]; if (argc != 4) usage(); fp = fopen(argv[3], "r"); if (!fp) return; if (srld_db_open(argv[2], O_RDWR|O_CREAT, &db) != SRLD_OK) { fprintf(stderr,"open(%s) failed: %s\n", argv[2], strerror(errno)); exit(errno); } while (fgets(json, BUFSZ, fp)) { if (srld_json_put(&db, json) != SRLD_OK) { fprintf(stderr,"writev() failed: %s\n", strerror(errno)); } } print_stats(stderr, 1); fclose(fp); srld_db_close(&db); }
/** * \brief Simulates the given \ref recipe based on provided \ref args * * \param[in] args The \ref args to the simulation * \param[in] recipe A generated \ref recipe to simulate */ void simulate_recipe(ARGS *args, RECIPE *recipe) { SC_DP_QC *sc_dp_qc; DP_QC *dp_qc; QC *qc; long int big_t; sc_dp_qc = create_sc_dp_qc(args, recipe); dp_qc = sc_dp_qc->dp_qc; qc = dp_qc->qc; // Disable error tracking qc->track = FALSE; // Let QC know about the boundaries qc->get_boundary = get_boundary; qc->boundaries = (void *)sc_dp_qc->boundaries; // Run the simulation // Now that the bootup process is complete, simulate as usual fprintf(args->out_raw, "p = %g\n" "d = %d\n" "big_t_max = %ld\n" "new t_check = %d\n" "t_delete = %d\n" "max_num_X = %d\n" "max_num_Z = %d\n" "verbose = %d\n" "s0 = %d;\n" "s1 = %d;\n" "-s0 %d -s1 %d\n", args->p, args->d, args->big_t_max, args->t_check, args->t_delete, args->max_num_X, args->max_num_Z, args->verbose, qc->s0, qc->s1, qc->s0, qc->s1); big_t = 0; while (big_t <= args->big_t_max && (sc_dp_qc->num_X_changes < args->max_num_X || sc_dp_qc->num_Z_changes < args->max_num_Z)) { measure_stabilizers(sc_dp_qc, big_t); qc_convert_nests(qc, FALSE); qc_mwpm(qc, FALSE); correct_mts(sc_dp_qc); // not quite sure why following needs -2 rather than -1 qc_trim_nests(qc, qc->unfinalized_big_t - 2); m_time_delete(qc->m_pr); m_time_delete(qc->m_du); if (args->cap_time > 0 && big_t == args->cap_time) { break; } if (big_t > 0 && big_t%args->t_check == 0) { test_correct(sc_dp_qc, args->out_raw); } if (args->verbose || (args->t_out > 0 && big_t%args->t_out == 0)) print_stats(sc_dp_qc, args->out_raw); assert(qc->big_t == big_t+1); big_t++; } /* printf("not in test_correct:\n"); printf("primal:\n"); // m_print_lattice(qc->m_pr); m_print_graph(qc->m_pr); printf("dual:\n"); // m_print_lattice(qc->m_du); m_print_graph(qc->m_du); */ free_sc_dp_qc(sc_dp_qc); }
/** * \brief Calculates the optimal value of t_check by running a preliminary boot * up simulation * * \param[in] args The arguments to the simulation * \param[in,out] recipe The \ref recipe to be used to calculate t_check */ void calculate_t_check(ARGS *args, RECIPE *recipe) { long int big_t; int changes; SC_DP_QC *sc_dp_qc; QC *qc; big_t = 0; // Initialise the Surface Code Depolarizing Quantum Computer sc_dp_qc = create_sc_dp_qc(args, recipe); qc = sc_dp_qc->dp_qc->qc; // Let QC know about the boundaries qc->track = FALSE; qc->get_boundary = get_boundary; qc->boundaries = (void *)sc_dp_qc->boundaries; // Output the initial variable state fprintf(args->out_raw, "p = %g\n" "d = %d\n" "big_t_max = %ld\n" "t_check = %d\n" "t_delete = %d\n" "max_num_X = %d\n" "max_num_Z = %d\n" "boot = %d\n" "boot_num_X = %d\n" "boot_num_Z = %d\n" "t_check_scale = %d\n" "verbose = %d\n" "s0 = %d;\n" "s1 = %d;\n" "-s0 %d -s1 %d\n", args->p, args->d, args->big_t_max, args->t_check, args->t_delete, args->max_num_X, args->max_num_Z, args->boot, args->boot_num_X, args->boot_num_Z, args->t_check_scale, args->verbose, qc->s0, qc->s1, qc->s0, qc->s1); while (TRUE) { measure_stabilizers(sc_dp_qc, big_t); qc_convert_nests(qc, FALSE); qc_mwpm(qc, FALSE); correct_mts(sc_dp_qc); qc_trim_nests(qc, qc->unfinalized_big_t - 2); m_time_delete(qc->m_pr); m_time_delete(qc->m_du); if (big_t > 0 && (big_t % args->t_check) == 0) { test_correct(sc_dp_qc, args->out_raw); // If we have gotten to 50 time checks and have yet to find a change, // double t_check or we'll be here all year. if (sc_dp_qc->num_X_changes == 0 && sc_dp_qc->num_Z_changes == 0 && sc_dp_qc->num_checks >= 50) { args->t_check <<= 1; fprintf(args->out_raw, "Doubling tcheck: %d\n", args->t_check); sc_dp_qc->num_checks = 0; } if (sc_dp_qc->num_X_changes >= args->boot_num_X || sc_dp_qc->num_Z_changes >= args->boot_num_Z) { changes = (sc_dp_qc->num_X_changes >= sc_dp_qc->num_Z_changes) ? sc_dp_qc->num_X_changes : sc_dp_qc->num_Z_changes; fprintf(args->out_raw, "Calculating tcheck: %d %d %d %d\n", args->t_check, sc_dp_qc->num_checks, changes, args->t_check_scale); args->t_check = args->t_check * sc_dp_qc->num_checks / changes / args->t_check_scale; if (args->t_check < 1) { args->t_check = 1; } recipe->repeated_count = 0; break; } } // If we are verbose, then print out the current SC_DP_QC statistics if (args->verbose) { print_stats(sc_dp_qc, args->out_raw); } // Ensure that the qc has been properly advanced in big_t assert(qc->big_t == big_t+1); big_t++; } // Free the sc_dp_qc now that the t_check has been calculated free_sc_dp_qc(sc_dp_qc); }
static void mainloop( struct batch_queue *queue ) { int workers_submitted = 0; struct itable *job_table = itable_create(0); struct list *masters_list = NULL; struct list *foremen_list = NULL; int64_t factory_timeout_start = time(0); while(!abort_flag) { if(config_file && !read_config_file(config_file)) { debug(D_NOTICE, "Error re-reading '%s'. Using previous values.", config_file); } else { set_worker_resources_options( queue ); batch_queue_set_option(queue, "autosize", autosize ? "yes" : NULL); } submission_regex = foremen_regex ? foremen_regex : project_regex; if(using_catalog) { masters_list = work_queue_catalog_query(catalog_host,catalog_port,project_regex); } else { masters_list = do_direct_query(master_host,master_port); } if(masters_list && list_size(masters_list) > 0) { factory_timeout_start = time(0); } else { // check to see if factory timeout is triggered, factory timeout will be 0 if flag isn't set if(factory_timeout > 0) { if(time(0) - factory_timeout_start > factory_timeout) { fprintf(stderr, "There have been no masters for longer then the factory timeout, exiting\n"); abort_flag=1; break; } } } debug(D_WQ,"evaluating master list..."); int workers_needed = count_workers_needed(masters_list, 0); int workers_connected = count_workers_connected(masters_list); debug(D_WQ,"%d total workers needed across %d masters", workers_needed, masters_list ? list_size(masters_list) : 0); if(foremen_regex) { debug(D_WQ,"evaluating foremen list..."); foremen_list = work_queue_catalog_query(catalog_host,catalog_port,foremen_regex); /* add workers on foremen. Also, subtract foremen from workers * connected, as they were not deployed by the pool. */ workers_needed += count_workers_needed(foremen_list, 1); workers_connected += MAX(count_workers_connected(foremen_list) - list_size(foremen_list), 0); debug(D_WQ,"%d total workers needed across %d foremen",workers_needed,list_size(foremen_list)); } debug(D_WQ,"raw workers needed: %d", workers_needed); if(workers_needed > workers_max) { debug(D_WQ,"applying maximum of %d workers",workers_max); workers_needed = workers_max; } if(workers_needed < workers_min) { debug(D_WQ,"applying minimum of %d workers",workers_min); workers_needed = workers_min; } int new_workers_needed = workers_needed - workers_submitted; if(workers_per_cycle > 0 && new_workers_needed > workers_per_cycle) { debug(D_WQ,"applying maximum workers per cycle of %d",workers_per_cycle); new_workers_needed = workers_per_cycle; } if(workers_per_cycle > 0 && workers_submitted > new_workers_needed + workers_connected) { debug(D_WQ,"waiting for %d previously submitted workers to connect", workers_submitted - workers_connected); new_workers_needed = 0; } debug(D_WQ,"workers needed: %d", workers_needed); debug(D_WQ,"workers submitted: %d", workers_submitted); debug(D_WQ,"workers requested: %d", new_workers_needed); print_stats(masters_list, foremen_list, workers_submitted, workers_needed, new_workers_needed, workers_connected); update_blacklisted_workers(queue, masters_list); if(new_workers_needed>0) { debug(D_WQ,"submitting %d new workers to reach target",new_workers_needed); workers_submitted += submit_workers(queue,job_table,new_workers_needed); } else if(new_workers_needed<0) { debug(D_WQ,"too many workers, will wait for some to exit"); } else { debug(D_WQ,"target number of workers is reached."); } debug(D_WQ,"checking for exited workers..."); time_t stoptime = time(0)+5; while(1) { struct batch_job_info info; batch_job_id_t jobid; jobid = batch_job_wait_timeout(queue,&info,stoptime); if(jobid>0) { if(itable_lookup(job_table,jobid)) { itable_remove(job_table,jobid); debug(D_WQ,"worker job %"PRId64" exited",jobid); workers_submitted--; } else { // it may have been a job from a previous run. } } else { break; } } delete_projects_list(masters_list); delete_projects_list(foremen_list); sleep(factory_period); } remove_all_workers(queue,job_table); itable_delete(job_table); }
int main(int argc, char **argv) { opterr = 0; while (1) { int c = getopt(argc, argv, "lbmunsot:pf:KMG"); if (c == -1) break; switch (c) { case 'l': display_mode = DISPLAY_LINUX; break; case 'b': display_mode = DISPLAY_BSD; break; case 'm': display_mode = DISPLAY_MRTG; break; case 'u': display_mode = DISPLAY_PLAIN; break; case 'n': repeat_mode = REPEAT_NONE; break; case 's': repeat_mode = REPEAT_FOREVER; break; case 'o': repeat_mode = REPEAT_ONCE; break; case 't': repeat_time = atoi(optarg); break; case 'p': use_cpu_percent = 1; break; case 'f': float_scale_factor = atol(optarg); break; case 'K': bytes_scale_factor = 1024; break; case 'M': bytes_scale_factor = 1024 * 1024; break; case 'G': bytes_scale_factor = 1024 * 1024 * 1024; break; default: usage(); } } if (display_mode == DISPLAY_MRTG) { if ((argc - optind) != 2) die("mrtg mode: must specify exactly two stats"); if (repeat_mode == REPEAT_FOREVER) die("mrtg mode: cannot repeat display"); } if (use_cpu_percent && repeat_mode == REPEAT_NONE) die("CPU percentage usage display requires stat differences"); if (repeat_mode == REPEAT_NONE) use_diffs = 0; else use_diffs = 1; select_interesting(argc - optind, &argv[optind]); /* We don't care if sg_init fails, because we can just display the statistics that can be read as non-root. */ sg_init(); sg_snapshot(); if (sg_drop_privileges() != 0) die("Failed to drop setuid/setgid privileges"); switch (repeat_mode) { case REPEAT_NONE: get_stats(); print_stats(argc, argv); break; case REPEAT_ONCE: get_stats(); sleep(repeat_time); sg_snapshot(); get_stats(); print_stats(argc, argv); break; case REPEAT_FOREVER: while (1) { get_stats(); print_stats(argc, argv); printf("\n"); sleep(repeat_time); sg_snapshot(); } } if (display_mode == DISPLAY_MRTG) { printf("\n"); printf("statgrab\n"); } sg_shutdown(); return 0; }
void CSearch::Evaluate() { const int empties = Empties(P, O); const int MAX_SELECTIVITY = 6; int D = MIN(static_cast<int>(depth), empties); if (depth >= empties) // Endgame { if (empties <= 14) { score = Eval(P, O, NodeCounter, alpha, beta, selectivity, empties, empties, &PV_line); print_stats(empties, selectivity); } else if (empties <= 20) { // Iterative deepening for (int d = D % 2; d <= D; d += 2) { if (empties - d >= 10) { score = Eval(P, O, NodeCounter, alpha, beta, MAX_SELECTIVITY, d, empties, &PV_line); print_stats(d, MAX_SELECTIVITY); } } // Iterative broadening for (int s : {6, 0}) score = Aspiration_Search(P, O, NodeCounter, alpha, beta, score, s, D, empties, PV_line); } else { // Initial Eval for (int d = D % 2; d <= D % 2 + 4; d += 2) { score = Eval(P, O, NodeCounter, alpha, beta, NO_SELECTIVITY, d, empties, &PV_line); print_stats(d, NO_SELECTIVITY); } // Iterative deepening for (int d = D % 2 + 4; d < D; d += 2) if (empties - d >= 10) score = Aspiration_Search(P, O, NodeCounter, alpha, beta, score, MAX_SELECTIVITY, d, empties, PV_line); if (empties < 30) { // Iterative broadening for (int s : {6, 4, 0}) score = Aspiration_Search(P, O, NodeCounter, alpha, beta, score, s, D, empties, PV_line); } else { // Iterative broadening for (int s : {6, 4, 3, 2, 1, 0}) score = Aspiration_Search(P, O, NodeCounter, alpha, beta, score, s, D, empties, PV_line); } } } else { if (D <= 3) { score = Eval(P, O, NodeCounter, alpha, beta, selectivity, D, empties, &PV_line); print_stats(D, selectivity); } else if (depth <= 10) { for (int d = D % 2; d <= D; d += 2) { score = Eval(P, O, NodeCounter, alpha, beta, MAX_SELECTIVITY, d, empties, &PV_line); print_stats(d, MAX_SELECTIVITY); } score = Eval(P, O, NodeCounter, alpha, beta, selectivity, D, empties, &PV_line); print_stats(D, selectivity); } else { for (int d = D % 2; d < D; d += 2) { if (empties - d >= 10) { score = Eval(P, O, NodeCounter, alpha, beta, MAX_SELECTIVITY, d, empties, &PV_line); print_stats(d, MAX_SELECTIVITY); } } // Iterative broadening for (int s : {6, 3, 0}) score = Aspiration_Search(P, O, NodeCounter, alpha, beta, score, s, D, empties, PV_line); } } //// Iterative deepening //for (int d = D % 2; d < D; d += 2) //{ // if (empties - d >= 10) // { // score = Eval(P, O, NodeCounter, m_alpha, m_beta, MAX_SELECTIVITY, d, empties, &PV_line); // print_stats(d, MAX_SELECTIVITY); // } //} //// Iterative broadening //for (int s = MAX_SELECTIVITY; s >= selectivity; s -= 2) //{ // score = Eval(P, O, NodeCounter, alpha, beta, s, D, empties, &PV_line); // print_stats(D, s); //} endTime = std::chrono::high_resolution_clock::now(); }