示例#1
0
void
workbook_style_test (Workbook *wb)
{
	GSList *sheets;

	g_return_if_fail (wb != NULL);

	sheets = workbook_sheets (wb);

	while (sheets) {
		Sheet *sheet = sheets->data;

		fprintf (stderr, "Style lookups on '%s'\n", sheet->name_unquoted);
		sheet_styles_dump (sheet);

#ifdef RUN_THRASH_SCROLL
		zero_stats ();
		thrash_scroll (sheet);
		dump_stats ("Scroll");
#endif

		zero_stats ();
		thrash_insert (sheet);
		dump_stats ("Insert");

		sheets = g_slist_remove (sheets, sheet);
		sheet_flag_recompute_spans (sheet);
	}
	workbook_recalc (wb);
	workbook_calc_spans (wb, GNM_SPANCALC_RENDER);
}
示例#2
0
void dump_hist_stats (void)
{
    double minavg, maxavg, avgavg;

    /* max is last, where its visible w/o scrolling */
    minavg = dump_histogram (histogram_min, "min");
    avgavg = dump_histogram (histogram_avg, "avg");
    maxavg = dump_histogram (histogram_max, "max");

    fprintf(stderr,"HSH|--param|--samples-|--average--|---stddev--\n");

    dump_stats (histogram_min, "min", minavg);
    dump_stats (histogram_avg, "avg", avgavg);
    dump_stats (histogram_max, "max", maxavg);
}
示例#3
0
void zbar_image_scanner_destroy (zbar_image_scanner_t *iscn)
{
	dump_stats(iscn);
	if(iscn->syms) {
		if(iscn->syms->refcnt)
			zbar_symbol_set_ref(iscn->syms, -1);
		else
			_zbar_symbol_set_free(iscn->syms);
		iscn->syms = NULL;
	}
	if(iscn->scn)
		zbar_scanner_destroy(iscn->scn);
	iscn->scn = NULL;
	if(iscn->dcode)
		zbar_decoder_destroy(iscn->dcode);
	iscn->dcode = NULL;
	int i;
	for(i = 0; i < RECYCLE_BUCKETS; i++) {
		zbar_symbol_t *sym, *next;
		for(sym = iscn->recycle[i].head; sym; sym = next) {
			next = sym->next;
			_zbar_symbol_free(sym);
		}
	}
#ifdef ENABLE_QRCODE
	if(iscn->qr) {
		_zbar_qr_destroy(iscn->qr);
		iscn->qr = NULL;
	}
#endif
	free(iscn);
}
示例#4
0
文件: main.cpp 项目: abb58/CMU24-623
int main(int argc, char** argv)
{
  // Set the random number for the positions
  srand (time(NULL));

  // Loop over #of trial moves
  std::ofstream enerFile;
  enerFile.open("LDmj_sim_dx-5.txt");

  for(int k=0; k<=n_moves; k++) {

    // Set the delta for the position 
    dx = dx_max * (2.0*(double(rand())/double(RAND_MAX)) - 1.0);

    // Compute U_trial
    compute_trial_parameters();

    // Metropolis Algorithm
    apply_metropolis();

    // kawasaki Algorithm
    // apply_kawasaki();
    // Write the output to a file
    if(k%100 == 0) {
      std::cout << std::setw(8)  << k  
		<< std::setw(12) << U   << std::setw(12) << x
		<< std::setw(15) << x*x << std::endl;
      dump_stats(enerFile, k);
    }
  }
  enerFile.close();
  std::cout << "Acceptance percentage : " << (double(count_acc)/double(n_moves))*100 << std::endl;
  return 0;
}
示例#5
0
int main(int argc, char **argv)
{
    int ret;
    struct sigaction act;

    time(&start_time);
    opts.outfile = 0;
    opts.poll_sleep = millis_to_timespec(POLL_SLEEP_MILLIS);
    opts.new_data_thresh = NEW_DATA_THRESH;
    opts.ms_per_sample = MS_PER_SAMPLE;
    opts.cpu_freq = CPU_FREQ;

    argp_parse(&parser_def, argc, argv, 0, 0, &opts);
    fprintf(stderr, "ms_per_sample = %ld\n", opts.ms_per_sample);


    /* ensure that if we get a signal, we'll do cleanup, then exit */
    act.sa_handler = close_handler;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    sigaction(SIGHUP,  &act, NULL);
    sigaction(SIGTERM, &act, NULL);
    sigaction(SIGINT,  &act, NULL);

    ret = monitor_tbufs();

    dump_stats();
    msync(new_qos, sizeof(_new_qos_data), MS_SYNC);
    disable_tracing();

    return ret;
}
示例#6
0
int main(int argc, char **argv) {
	int i;
	
	__e(argc != 2);
	spawn = atoi(argv[1]);

	__w(spawn == 1, "Why do you want to run this?");

	/* Spawn a thread for each procesor */
	pthread_t thread[32];
	for (i=0; i < spawn; i++) {
		pthread_create(&thread[i], NULL, &state_machine, (void*)(long)i);
	}

	/*
	 * Assembly point
	 */
	for (i=0; i < spawn; i++) {
		pthread_join(thread[i], NULL);
	}

	dump_stats(spawn);

	return 0;
}
示例#7
0
文件: analyze.c 项目: ares89/vlc
void flac__analyze_finish(analysis_options aopts)
{
	if(aopts.do_residual_gnuplot) {
		compute_stats(&all_);
		(void)dump_stats(&all_, "all");
	}
}
示例#8
0
static void int_exit(int sig)
{
	(void)sig;
	dump_stats();
	bpf_set_link_xdp_fd(opt_ifindex, -1, opt_xdp_flags);
	exit(EXIT_SUCCESS);
}
示例#9
0
文件: fitness.c 项目: emkev/genetic
int main(int argc , char **argv)
{
  int i , j , t , targetlen , parent_a , parent_b ;
  int *numcorrect; 
  char **newpop , **oldpop , **swap;
  double *normfit;

  //srandom(seed);
  srand((unsigned)time(NULL));

  // whether to consider forcing the size to be even . 

  targetlen = 10;
  printf("hello! \n");
  newpop = malloc(sizeof(char *) * size);
  oldpop = malloc(sizeof(char *) * size);
  printf("hello 1-1 \n");
  numcorrect = malloc(sizeof(int) * size);
  normfit = malloc(sizeof(double) * size);
  printf("hello2 \n");
  for(i = 0 ; i < size ; i++)
  {
    newpop[i] = malloc(sizeof(char) * targetlen + 1);
    oldpop[i] = malloc(sizeof(char) * targetlen + 1);
    for(j = 0 ; j < targetlen ; j++)
    {
      oldpop[i][j] = random_letter_or_space();
    }
    newpop[i][targetlen] = 0;
    oldpop[i][targetlen] = 0;
  }

  for(t = 0 ; t < steps ; t++)
  {
    compute_fitness(oldpop , numcorrect , normfit);
    dump_stats(numcorrect , oldpop , t + 1 , targetlen);
    for(i = 0 ; i < size ; i += 2)
    {
      parent_a = select_one(normfit);
      parent_b = select_one(normfit);
      // whether to add parent_a can not be equal to parent_b .  
      //printf("p_a = %d , p_b = %d \n" , parent_a , parent_b);
      reproduce(oldpop , newpop , parent_a , parent_b , targetlen , i);
    }
    
    swap = oldpop;
    oldpop = newpop;
    newpop = swap; 
    /*
    swap = newpop;
    newpop = oldpop;
    oldpop = swap;
    */
  }
  exit(0);
}
示例#10
0
static void
test_dump_stats_succeeds_without_entries() {
  assert_true( init_stat() );

  expect_string( mock_info, message, "Statistics:" );
  expect_string( mock_info, message, "No statistics found." );
  dump_stats();

  assert_true( finalize_stat() );
}
示例#11
0
static void *poller(void *arg)
{
	(void)arg;
	for (;;) {
		sleep(opt_interval);
		dump_stats();
	}

	return NULL;
}
示例#12
0
文件: encode.c 项目: GGGO/baresip
static void destructor(void *arg)
{
	struct videnc_state *ves = arg;

	if (ves->stats.valid)
		dump_stats(ves);

	if (ves->enc)
		daala_encode_free(ves->enc);
}
示例#13
0
文件: trie.c 项目: jeffli999/bitband
// trie construction with a depth-first traverse (dfs)
Trie* build_trie(Rule *rules, int nrules, int leaf_rules)
{
	Trie*	v;
	int		i;

	total_rules = nrules;
	LEAF_RULES = leaf_rules;
	root_node = init_trie(rules, nrules);
	create_children(root_node);

	dump_stats();
}
示例#14
0
static void cleanup(void)
{
    nplNotice("Exiting...\0");
    dump_stats();
    (void)lpqClose(ldmProdQueue);

    if (shm != NULL) {
       shmfifo_detach(shm);
       shmfifo_free(shm);

       shm = NULL;
    }
}
示例#15
0
static void
test_dump_stats_succeeds() {
  assert_true( init_stat() );

  const char *key = "key";
  increment_stat( key );

  expect_string( mock_info, message, "Statistics:" );
  expect_string( mock_info, message, "key: 1" );
  dump_stats();

  assert_true( finalize_stat() );
}
int main(int argc, char **argv) {
    uint8_t sz2 = 12;
    uint8_t max_threads = 8;

    char *sz2_env = getenv("SZ2");
    char *max_threads_env = getenv("MAX_THREADS");
    if (sz2_env) { sz2 = atoi(sz2_env); }
    if (max_threads_env) { max_threads = atoi(max_threads_env); }

    struct threadpool_config cfg = {
        .task_ringbuf_size2 = sz2,
        .max_threads = max_threads,
    };
    struct threadpool *t = Threadpool_Init(&cfg);
    assert(t);

    struct threadpool_task task = {
        .task = task_cb, .udata = t,
    };

    struct threadpool_info stats;

    struct timeval tv;
    gettimeofday(&tv, NULL);
    time_t last_sec = tv.tv_sec;
    size_t counterpressure = 0;
    size_t ticks = 0;

    for (;;) {
        gettimeofday(&tv, NULL);
        if (tv.tv_sec > last_sec) {
            last_sec = tv.tv_sec;
            Threadpool_Stats(t, &stats);
            ticks++;
            dump_stats("tick...", &stats, ticks);
        }

        /* Every 16 seconds, pause scheduling for 5 seconds to test
         * thread sleep/wake-up alerts. */
        if ((ticks & 15) == 0) {
            sleep(5);
        }

        for (size_t i = 0; i < 1000; i++) {
            if (!Threadpool_Schedule(t, &task, &counterpressure)) {
                size_t msec = i * 1000 * counterpressure;
                usleep(msec >> 12);
            } else {
                break;
            }
        }
int main(int argc, char *argv[])
{
	struct nl_handle *nlh;
	struct nl_cache *link_cache;
	int err = 1;

	if (nltool_init(argc, argv) < 0)
		return -1;

	if (argc < 3 || !strcmp(argv[1], "-h"))
		print_usage();

	nlh = nltool_alloc_handle();
	if (!nlh)
		return -1;

	if (nltool_connect(nlh, NETLINK_ROUTE) < 0)
		goto errout;

	link_cache = nltool_alloc_link_cache(nlh);
	if (!link_cache)
		goto errout_close;

	gargv = &argv[2];
	gargc = argc - 2;

	if (!strcasecmp(argv[1], "all"))
		nl_cache_foreach(link_cache, dump_stats, NULL);
	else {
		int ifindex = strtoul(argv[1], NULL, 0);
		struct rtnl_link *link = rtnl_link_get(link_cache, ifindex);

		if (!link) {
			fprintf(stderr, "Could not find ifindex %d\n", ifindex);
			goto errout_link_cache;
		}

		dump_stats((struct nl_object *) link, NULL);
		rtnl_link_put(link);
	}

	err = 0;
errout_link_cache:
	nl_cache_free(link_cache);
errout_close:
	nl_close(nlh);
errout:
	nl_handle_destroy(nlh);
	return err;
}
示例#18
0
void sigproc(int sig) {
  static int called = 0;
 
  fprintf(stderr, "Leaving...\n");
  if(called) return; else called = 1;
  do_shutdown = 1;
  
  dump_stats();
  print_stats();
  
  pfring_breakloop(pd);


}
示例#19
0
static void
cleanup(void)
{
        log_notice("Exiting");

        dump_stats(&stats);

        if(pq != NULL)  
        {
                (void)pq_close(pq);
                pq = NULL;
        }

        log_fini();
}
示例#20
0
文件: main.cpp 项目: abb58/CMU24-623
int main(int argc, char** argv)
{
  const char filename[]="10.txt";

  // Determine the number of atoms
  Natoms = get_natoms(filename);

  // Initialize the positions !
  init(Natoms, filename);

  // Loop over timesteps
  std::ofstream simFile,enerFile;
  simFile.open("LDmj_sim.xyz");
  enerFile.open("LDmj_sim.ener");
  enerFile << "Time step" << std::setw(15) << "time"
	   << std::setw(15) << "PE" << std::setw(15) << "KE"
	   << std::setw(15) << "TE" << std::setw(15) << "Px"
	   << std::setw(15) << "Py" << std::setw(15)
	   << "Pz" << std::setw(15) << std::endl;

  for(int k=0; k<=1000; k++) {
    elapsed_time = dt*double(k);

    // Calculate pair-energy and forces
    if(k==0) calc_force();

    calc_kenergy();
    TE=U+KE;

    std::cout << std::setw(8)  << k  << std::setw(15) << elapsed_time
	      << std::setw(15) << U  << std::setw(15) << KE
	      << std::setw(15) << TE << std::setw(15) << px
	      << std::setw(15) << py << std::setw(15) << pz
	      << std::setw(15) << std::endl;

    calc_momentum();
    write_xyz(simFile, k);
    dump_stats(enerFile, k);

    // parameters are computed for (i+1)
    vv_scheme();
  }
  
  simFile.close();
  enerFile.close();
  
  return 0;
}
示例#21
0
void dump_histogram(void)
{
	int n, total_hits = 0;
	double sum = 0;
	fprintf(stderr, "---|---range-|---samples\n");
	for (n = 0; n < HISTOGRAM_CELLS; n++) {
		long hits = histogram[n];
		if (hits) {
			total_hits += hits;
			sum += n * hits;
			fprintf(stderr, "HSD| %d - %d | %10ld\n",
				n, n + 1, hits);
		}
	}
	dump_stats(sum, total_hits);
}
示例#22
0
文件: gabump.c 项目: Stray/CBofN
int main(int argc, char **argv)
{
  int i, j, t, parent_a, parent_b;
  char **swap, **newpop, **oldpop;
  double *fit, *normfit;
  
  get_options(argc, argv, options, help_string);

  srandom(seed);

  /* Force the size to be even. */
  size += (size / 2 * 2 != size);

  /* Initialize the population. */
  newpop = xmalloc(sizeof(char *) * size);
  oldpop = xmalloc(sizeof(char *) * size);
  fit = xmalloc(sizeof(double) * size);
  normfit = xmalloc(sizeof(double) * size);
  for(i = 0; i < size; i++) {
    newpop[i] = xmalloc(sizeof(char) * len + 1);
    oldpop[i] = xmalloc(sizeof(char) * len + 1);
    for(j = 0; j < len; j++)
      oldpop[i][j] = random() % 2 + '0';
    oldpop[i][len] = 0;
    newpop[i][len] = 0;
  }

  /* For each time step... */
  for(t = 0; t < gens; t++) {
    compute_fitness(oldpop, fit, normfit);
    dump_stats(t, oldpop, fit);

    /* Pick two parents by fitness and mate them until the
     * next generation has been made.
     */
    for(i = 0; i < size; i += 2) {
      parent_a = select_one(normfit);
      parent_b = select_one(normfit);
      reproduce(oldpop, newpop, parent_a, parent_b, i);
    }
    /* Make everything old new again. */
    swap = newpop; newpop = oldpop; oldpop = swap;
  }

  exit(0);
}
示例#23
0
static void  *stats_thr( void *arg )
{
    struct tm      date;

    strftime( start_time_str, 256, "%Y/%m/%d %T", localtime_r( &start_time, &date ) );

    if (!ensure_db_access())
        return NULL;

    DisplayLog( LVL_VERB, DIFF_TAG, "Statistics thread started" );

    while ( 1 )
    {
        WaitStatsInterval(  );
        dump_stats(&lmgr);
    }
}
void do_observe(void) {
    while (1) {
        do_run();

        switch (exception) {
        case NO_EXCEPTION:
            break;
        case EXCEPTION_QUIT:
            dump_stats();
            return;
        case EXCEPTION_FATAL:
            fprintf(stderr, "Fatal error...\n");
            return;
        case EXCEPTION_BACKTRACK:
            worldsens_scheduler_backtrack();
            break;
        }
    }
}
示例#25
0
int periodic_work() {
  int rc = -1, kc;
  shift_buffers();
  dump_stats();

#if 1
  while (have_capacity()) {
    kc = kv_spool_read(cfg.sp,cfg.set,0);
    if (kc <  0) goto done; // error
    if (kc == 0) break;     // no data
    cfg.ompp++;
    if (set_to_binary(cfg.set, cfg.s)) goto done;
    append_to_client_buf(cfg.s);
  }
  mark_writable();
#endif
  rc = 0;

 done:
  return rc;
}
示例#26
0
static void task_cb(void *udata) {
    struct threadpool *t = (struct threadpool *)udata;

    for (;;) {
        if (ATOMIC_BOOL_COMPARE_AND_SWAP(&task_count, task_count, task_count + 1)) {
            break;
        }
    }

    size_t arg = task_count;
    arg = 30 + (random() % 10);

    size_t tc = task_count;

    size_t res = fibs(arg);

    printf("%zd -- fibs(%zd) => %zd", tc, arg, res);

    struct threadpool_info stats;
    Threadpool_Stats(t, &stats);
    dump_stats("", &stats);
}
示例#27
0
文件: pqsurf.c 项目: funnelfiasco/LDM
void
cleanup(void)
{
        unotice("Exiting"); 

        if(act_pid != -1)
        {
                (void)signal(SIGCHLD, SIG_IGN);
                kill(act_pid, SIGTERM);
                (void) reap_act(0);
        }

        if(opq != NULL)
        {
                off_t highwater = 0;
                size_t maxregions = 0;
                (void) pq_highwater(opq, &highwater, &maxregions);
                (void) pq_close(opq);
                opq = NULL;

                unotice("  Queue usage (bytes):%8ld",
                                        (long)highwater);
                unotice("           (nregions):%8ld",
                                        (long)maxregions);
        }

        if(pq != NULL)
        {
                (void) pq_close(pq);
                pq = NULL;
        }

        dump_stats();

        (void) closeulog();
}
示例#28
0
文件: analyze.c 项目: ares89/vlc
void flac__analyze_frame(const FLAC__Frame *frame, unsigned frame_number, FLAC__uint64 frame_offset, unsigned frame_bytes, analysis_options aopts, FILE *fout)
{
	const unsigned channels = frame->header.channels;
	char outfilename[1024];
	subframe_stats_t stats;
	unsigned i, channel, partitions;

	/* do the human-readable part first */
#ifdef __MSVCRT__
	fprintf(fout, "frame=%u\toffset=%I64u\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
#else
	fprintf(fout, "frame=%u\toffset=%llu\tbits=%u\tblocksize=%u\tsample_rate=%u\tchannels=%u\tchannel_assignment=%s\n", frame_number, (unsigned long long)frame_offset, frame_bytes*8, frame->header.blocksize, frame->header.sample_rate, channels, FLAC__ChannelAssignmentString[frame->header.channel_assignment]);
#endif
	for(channel = 0; channel < channels; channel++) {
		const FLAC__Subframe *subframe = frame->subframes+channel;
		const FLAC__bool is_rice2 = subframe->data.fixed.entropy_coding_method.type == FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2;
		const unsigned pesc = is_rice2? FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2_ESCAPE_PARAMETER : FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE_ESCAPE_PARAMETER;
		fprintf(fout, "\tsubframe=%u\twasted_bits=%u\ttype=%s", channel, subframe->wasted_bits, FLAC__SubframeTypeString[subframe->type]);
		switch(subframe->type) {
			case FLAC__SUBFRAME_TYPE_CONSTANT:
				fprintf(fout, "\tvalue=%d\n", subframe->data.constant.value);
				break;
			case FLAC__SUBFRAME_TYPE_FIXED:
				FLAC__ASSERT(subframe->data.fixed.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2);
				fprintf(fout, "\torder=%u\tresidual_type=%s\tpartition_order=%u\n", subframe->data.fixed.order, is_rice2? "RICE2":"RICE", subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order);
				for(i = 0; i < subframe->data.fixed.order; i++)
					fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.fixed.warmup[i]);
				partitions = (1u << subframe->data.fixed.entropy_coding_method.data.partitioned_rice.order);
				for(i = 0; i < partitions; i++) {
					unsigned parameter = subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->parameters[i];
					if(parameter == pesc)
						fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.fixed.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]);
					else
						fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter);
				}
				if(aopts.do_residual_text) {
					for(i = 0; i < frame->header.blocksize-subframe->data.fixed.order; i++)
						fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.fixed.residual[i]);
				}
				break;
			case FLAC__SUBFRAME_TYPE_LPC:
				FLAC__ASSERT(subframe->data.lpc.entropy_coding_method.type <= FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2);
				fprintf(fout, "\torder=%u\tqlp_coeff_precision=%u\tquantization_level=%d\tresidual_type=%s\tpartition_order=%u\n", subframe->data.lpc.order, subframe->data.lpc.qlp_coeff_precision, subframe->data.lpc.quantization_level, is_rice2? "RICE2":"RICE", subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order);
				for(i = 0; i < subframe->data.lpc.order; i++)
					fprintf(fout, "\t\tqlp_coeff[%u]=%d\n", i, subframe->data.lpc.qlp_coeff[i]);
				for(i = 0; i < subframe->data.lpc.order; i++)
					fprintf(fout, "\t\twarmup[%u]=%d\n", i, subframe->data.lpc.warmup[i]);
				partitions = (1u << subframe->data.lpc.entropy_coding_method.data.partitioned_rice.order);
				for(i = 0; i < partitions; i++) {
					unsigned parameter = subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->parameters[i];
					if(parameter == pesc)
						fprintf(fout, "\t\tparameter[%u]=ESCAPE, raw_bits=%u\n", i, subframe->data.lpc.entropy_coding_method.data.partitioned_rice.contents->raw_bits[i]);
					else
						fprintf(fout, "\t\tparameter[%u]=%u\n", i, parameter);
				}
				if(aopts.do_residual_text) {
					for(i = 0; i < frame->header.blocksize-subframe->data.lpc.order; i++)
						fprintf(fout, "\t\tresidual[%u]=%d\n", i, subframe->data.lpc.residual[i]);
				}
				break;
			case FLAC__SUBFRAME_TYPE_VERBATIM:
				fprintf(fout, "\n");
				break;
		}
	}

	/* now do the residual distributions if requested */
	if(aopts.do_residual_gnuplot) {
		for(channel = 0; channel < channels; channel++) {
			const FLAC__Subframe *subframe = frame->subframes+channel;
			unsigned residual_samples;

			init_stats(&stats);

			switch(subframe->type) {
				case FLAC__SUBFRAME_TYPE_FIXED:
					residual_samples = frame->header.blocksize - subframe->data.fixed.order;
					for(i = 0; i < residual_samples; i++)
						update_stats(&stats, subframe->data.fixed.residual[i], 1);
					break;
				case FLAC__SUBFRAME_TYPE_LPC:
					residual_samples = frame->header.blocksize - subframe->data.lpc.order;
					for(i = 0; i < residual_samples; i++)
						update_stats(&stats, subframe->data.lpc.residual[i], 1);
					break;
				default:
					break;
			}

			/* update all_ */
			for(i = 0; i < stats.nbuckets; i++) {
				update_stats(&all_, stats.buckets[i].residual, stats.buckets[i].count);
			}

			/* write the subframe */
			sprintf(outfilename, "f%06u.s%u.gp", frame_number, channel);
			compute_stats(&stats);

			(void)dump_stats(&stats, outfilename);
		}
	}
}
示例#29
0
static void
test_dump_stats_fails_if_not_initialized() {
  expect_assert_failure( dump_stats() );
}
示例#30
0
static void   *signal_handler_thr( void *arg )
{
    struct sigaction act_sigterm;
    struct sigaction act_sigusr;

    /* create signal handlers */
    memset( &act_sigterm, 0, sizeof( act_sigterm ) );
    act_sigterm.sa_flags = 0;
    act_sigterm.sa_handler = terminate_handler;
    if ( sigaction( SIGTERM, &act_sigterm, NULL ) == -1
         || sigaction( SIGINT, &act_sigterm, NULL ) == -1 )
    {
        DisplayLog( LVL_CRIT, SIGHDL_TAG,
                    "Error while setting signal handlers for SIGTERM and SIGINT: %s",
                    strerror( errno ) );
        if (options.diff_arg.db_tag != NULL && ensure_db_access())
        {
            fprintf(stderr, "Cleaning diff table...\n");
            ListMgr_DestroyTag(&lmgr, options.diff_arg.db_tag);
        }
        exit( 1 );
    }
    else
        DisplayLog( LVL_EVENT, SIGHDL_TAG,
                    "Signals SIGTERM and SIGINT (daemon shutdown) are ready to be used" );

    memset( &act_sigusr, 0, sizeof( act_sigusr ) );
    act_sigusr.sa_flags = 0;
    act_sigusr.sa_handler = usr_handler;
    if ( sigaction( SIGUSR1, &act_sigusr, NULL ) == -1 )
    {
        DisplayLog( LVL_CRIT, SIGHDL_TAG, "Error while setting signal handlers for SIGUSR1: %s",
                    strerror( errno ) );
        if (options.diff_arg.db_tag != NULL && ensure_db_access())
        {
            fprintf(stderr, "Cleaning diff table...\n");
            ListMgr_DestroyTag(&lmgr, options.diff_arg.db_tag);

            /* make sure written data is flushed */
            if (options.diff_arg.lovea_file)
                fflush(options.diff_arg.lovea_file);
            if (options.diff_arg.fid_remap_file)
                fflush(options.diff_arg.fid_remap_file);
        }
        exit( 1 );
    }
    else
        DisplayLog( LVL_EVENT, SIGHDL_TAG, "Signal SIGUSR1 (stats dump) is ready to be used" );


    /* signal flag checking loop */

    while ( 1 )
    {
        /* check for signal every second */
        rh_sleep( 1 );

        if ( terminate_sig != 0 )
        {
            if ( terminate_sig == SIGTERM )
                DisplayLog( LVL_MAJOR, SIGHDL_TAG, "SIGTERM received: performing clean daemon shutdown" );
            else if ( terminate_sig == SIGINT )
                DisplayLog( LVL_MAJOR, SIGHDL_TAG, "SIGINT received: performing clean daemon shutdown" );
            FlushLogs(  );

            /* stop FS scan (blocking) */
            FSScan_Terminate(  );
            FlushLogs(  );

            /* drop pipeline waiting operations and terminate threads */
            EntryProcessor_Terminate( FALSE );
            FlushLogs(  );

#ifdef _HSM_LITE
            /* shutdown backend access */
            Backend_Stop();
#endif

            DisplayLog( LVL_MAJOR, SIGHDL_TAG, "Exiting." );
            FlushLogs(  );

            if (options.diff_arg.db_tag != NULL && ensure_db_access())
            {
                fprintf(stderr, "Cleaning diff table...\n");
                ListMgr_DestroyTag(&lmgr, options.diff_arg.db_tag);

                /* make sure written data is flushed */
                if (options.diff_arg.lovea_file)
                    fflush(options.diff_arg.lovea_file);
                if (options.diff_arg.fid_remap_file)
                    fflush(options.diff_arg.fid_remap_file);
            }

            /* indicate the process terminated due to a signal */
            exit( 128 + terminate_sig );
        }
        else if ( dump_sig )
        {
            DisplayLog( LVL_MAJOR, SIGHDL_TAG, "SIGUSR1 received: dumping stats" );

            if (!ensure_db_access())
                return NULL;
            dump_stats(&lmgr);
            dump_sig = FALSE;
        }
    }
}