Example #1
0
static void bench_record(const SkPicture& src,
                         const double timerOverhead,
                         const char* name,
                         SkBBHFactory* bbhFactory) {
    // Rerecord once to warm up any caches.  Otherwise the first sample can be very noisy.
    rerecord(src, bbhFactory);

    // Rerecord once to see how many times we should loop to make timer overhead insignificant.
    Timer timer;
    do {
        timer.start(timescale());
        rerecord(src, bbhFactory);
        timer.end();
    } while (timer.fWall < timerOverhead);   // Loop just in case something bizarre happens.

    // We want (timer overhead / measurement) to be less than FLAGS_overheadGoal.
    // So in each sample, we'll loop enough times to have made that true for our first measurement.
    const int loops = (int)ceil(timerOverhead / timer.fWall / FLAGS_overheadGoal);

    SkAutoTMalloc<double> samples(FLAGS_samples);
    for (int i = 0; i < FLAGS_samples; i++) {
        timer.start(timescale());
        for (int j = 0; j < loops; j++) {
            rerecord(src, bbhFactory);
        }
        timer.end();
        samples[i] = timer.fWall / loops;
    }

    Stats stats(samples.get(), FLAGS_samples);
    if (FLAGS_verbose == 0) {
        printf("%g\t%s\n", stats.min, name);
    } else if (FLAGS_verbose == 1) {
        // Get a rough idea of how noisy the measurements were.
        const double noisePercent = 100 * sqrt(stats.var) / stats.mean;
        printf("%g\t%g\t%g\t±%.0f%%\t%s\n", stats.min, stats.mean, stats.max, noisePercent, name);
    } else if (FLAGS_verbose == 2) {
        printf("%s", name);
        for (int i = 0; i < FLAGS_samples; i++) {
            printf("\t%g", samples[i]);
        }
        printf("\n");
    }
}
Example #2
0
void copyouttest()
{

	int n,j,k; 
	double start,end;
	double meantime, sd, hm; 
	//  double getclock(void); 
	n=IDA;
	//printf("\n");
	//	printf("--------------------------------------------------------\n");
	//	printf("Computing COPYOUT %d time\n", n); 
#pragma acc data create(btest[0:n])
	for (k=0; k<=OUTERREPS; k++){
		//	START  = GETCLOCK();
		gettimeofday(&tim, NULL);
		start=tim.tv_sec*1000000.0 + tim.tv_usec;
		//#PRAGMA ACC KERNELS COPYIN(BTEST[0:N]) 
		//#PRAGMA ACC LOOP INDEPENDENT 

#pragma acc data pcopyout(btest[0:n])
		int i ;
		//ragma acc loop independent			
		//		for (j=0; j<innerreps; j++){
		//#PRAGMA OMP PARALLEL COPYIN(BTEST) 
		//			{
		//				delay(delaylength, btest); 
		//			}     
		//		}

		gettimeofday(&tim, NULL);
		end=tim.tv_sec*1000000.0 + (tim.tv_usec);
		times[k] = ( end - start ) ;
	}


	//	stats (&meantime, &sd);

	stats (&meantime, &sd, &hm);
	//	printf("%d: COPYOUT time =  %10.3f microseconds +/- %10.3f\n", n, meantime, CONF95*sd);
	printf("%d: COPYOUT time =  %10.3f microseconds +/- %10.3f\n", n, hm, CONF95*sd);

	//	printf("COPYOUT overhead =                       %10.3f microseconds +/- %10.3f\n", meantime-reftime, CONF95*(sd+refsd));

}
Example #3
0
            /**
             * Assemble an area from the given relation and its members.
             * The resulting area is put into the out_buffer.
             *
             * @returns false if there was some kind of error building the
             *          area(s), true otherwise.
             */
            bool operator()(const osmium::Relation& relation, const std::vector<const osmium::Way*>& members, osmium::memory::Buffer& out_buffer) {
                if (!config().create_new_style_polygons) {
                    return true;
                }

                assert(relation.cmembers().size() >= members.size());

                if (config().problem_reporter) {
                    config().problem_reporter->set_object(osmium::item_type::relation, relation.id());
                }

                if (relation.members().empty()) {
                    ++stats().no_way_in_mp_relation;
                    return false;
                }

                ++stats().from_relations;
                stats().invalid_locations = segment_list().extract_segments_from_ways(config().problem_reporter,
                                                                                      stats().duplicate_nodes,
                                                                                      stats().duplicate_ways,
                                                                                      relation,
                                                                                      members);
                if (!config().ignore_invalid_locations && stats().invalid_locations > 0) {
                    return false;
                }
                stats().member_ways = members.size();

                if (stats().member_ways == 1) {
                    ++stats().single_way_in_mp_relation;
                }

                if (config().debug_level > 0) {
                    std::cerr << "\nAssembling relation " << relation.id() << " containing " << members.size() << " way members with " << segment_list().size() << " nodes\n";
                }

                // Now create the Area object and add the attributes and tags
                // from the relation.
                bool okay = create_area(out_buffer, relation, members);
                if (okay) {
                    out_buffer.commit();
                } else {
                    out_buffer.rollback();
                }

                return okay;
            }
Example #4
0
Integrator::Status RQMCIntegrator::integrate(
        Integrand &f,
        const Hypercube &h,
        Index n, real, real,
        EstErr &ee)
{
    checkDimension(h, f);

    if (n == 0)
    {
        ee.set(0.0, 0.0);
        return ERROR;
    }

    ps->setCube(&h);
    n = ps->getOptimalNumber(n, h);
    ps->enableRandomize();

    if (randCount == 0) return ERROR;
    int m = n / randCount;

    std::vector<Statistic<>> stats(randCount);
    std::default_random_engine e(globalSeed);

    for (unsigned int i = 0; i < randCount; i++)
    {
        Statistic<> s;
        Point point(h.getDimension());
        int seed = e();
        ps->randomize(seed);
        ps->integrate(point, f, m, s);
        stats[i] = s;
    }

    std::vector<double> estimates;
    estimates.reserve(randCount);
    for (auto x : stats) estimates.push_back(x.getMean() * h.getVolume());
    double rqmcEst = sum(estimates) / randCount;
    double rqmcStdError = std::sqrt(var(estimates) / randCount);
    if (randCount == 1) rqmcStdError = 0;
    ee.set(rqmcEst, rqmcStdError);
    return MAX_EVAL_REACHED;
}
Example #5
0
    virtual int init(
        int argc,
        char *argv[]
    )
    {
        curBlock = 0;
        lastBlock = 0;
        firstBlock = 0;

        addrMap.setEmptyKey(emptyKey);
        addrMap.resize(15 * 1000 * 1000);
        allAddrs.reserve(15 * 1000 * 1000);

        option::Stats  stats(usageDescriptor, argc, argv);
        option::Option *buffer  = new option::Option[stats.buffer_max];
        option::Option *options = new option::Option[stats.options_max];
        option::Parser parse(usageDescriptor, argc, argv, options, buffer);
        if(parse.error()) exit(1);

        for(int i=0; i<parse.nonOptionsCount(); ++i) {
            loadKeyList(restricts, parse.nonOption(i));
        }

        if(0!=restricts.size()) {
            info(
                "restricting output to %" PRIu64 " addresses ...\n",
                (uint64_t)restricts.size()
            );

            auto e = restricts.end();
            auto i = restricts.begin();
            restrictMap.setEmptyKey(emptyKey);
            while(e!=i) {
                const uint160_t &h = *(i++);
                restrictMap[h.v] = 1;
            }
        }

        info("analyzing blockchain ...");
        delete [] options;
        delete [] buffer;
        return 0;
    }
Example #6
0
IHSFinder::LineMap IHSFinder::normalize()
{
    StatsMap iHSStatsByFreq;
    
    for(const auto& it : m_unStandIHSByFreq)
    {
        iHSStatsByFreq[it.first] = stats(it.second);
    }
    
    for (const auto& it : m_unStandIHSByLine)
    {
        double freq = m_freqsByLine[it.first];
        if (iHSStatsByFreq[freq].stddev == 0)
            continue;
        m_standIHSSingle[it.first] = (it.second - iHSStatsByFreq[freq].mean)/iHSStatsByFreq[freq].stddev;
    }
    
    return m_standIHSSingle;
}
Example #7
0
/* this is for check only. With this we make sure that all pointers we
   put into tree on pass 1 do not point to leaves (FIXME), do not
   point to journal, bitmap, etc, do not point out of fs boundary and
   are marked used in on-disk bitmap */
int still_bad_unfm_ptr_1 (unsigned long block)
{
    if (!block)
	return 0;
    if (pass0_is_leaf (block))
	return 1;
    if (pass0_is_bad_unfm (block) && !is_bad_unfm_in_tree_once (block))
	return 1;
    if (not_data_block (fs, block))
	return 1;
    /*
    if (!was_block_used (block))
	return 1;
    */
    if (block >= stats (fs)->all_blocks)
	return 1;
    return 0;
    
}
Example #8
0
void run_learn_predict_test(bool& ok) {
	test_tool t("test/digits/learn_predict", ok);

	typedef recognition_problem p;

	reexp::lang<p> lang;
	reexp::data<p> data(lang, sample_dim());
	setup_reg<p>(lang, data);

	reexp::stats<p> stats(data);

	reexp::learner<p> learner(lang, stats);
	setup_learner(learner);

	int rounds = 3;

	for (int i = 0; i < rounds; i++) {
		float before = stats.ndl();
		if (!learner.add_exp()) break;
		t<<"expression added."<<checkl;
		float after = stats.ndl();
		t<<"info "<<before<<" -> "<<after<<checkl<<checkl;
	}

	t<<checkl<<"learning done."<<checkl<<checkl;

	print_scan(t, lang, stats);

	reexp::pinfo info;
	setup_pinfo(info);
	reexp::lang_info<p> li(info, lang);

	t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y);

	t<<"px"<<checkl<<checkl;
	print_pixels(t, data.var(varid::pixel));
	for (int i = 0; i < rounds; i++) {
		t<<"exp"<<i<<checkl<<checkl;
		print_pixels(t, data.var(varid::digit9 + i + 1));
	}

	print_prediction<p>(t, stats);
}
Example #9
0
/* side effect: process given command */
int process_command(char *cmd)
{
  char *cmd_after;
  if (strcmp(cmd,"exit")==0){
    return 1;
  } else if (strcmp(cmd,"help")==0 || strcmp(cmd, "?") == 0){
    help();
  } else if (strcmp("read", cmd) == 0 || strcmp("r", cmd) == 0){
    printf("read what?\n");
  } else if (strcmp("read ", cmd) < -26 || strcmp("r ", cmd) < -26){
    int n = read(cmd);
    if(n == 1){
      printf("   -error: this file-name does not exist\n");
      return 0;
    } else if(n == 2){
      printf("   -error: this file is not a well formed .dwg file\n");
      return 0;
    } else{
      printf("********************************\n");
      printf("working in file: %s\n", curr_file);
      printf("********************************\n");
    }
  } else if (strcmp(cmd, "stats") == 0 || strcmp(cmd, "s") == 0){
    printf("usage: [-f] [-n] [-v] or [-c] required\n");
  } else if (strcmp("stats ", cmd) < -26 || strcmp("s ", cmd) < -26){
    if(curr_file == NULL){
      printf("must be working in a file first\n");
      return 0;
    }
    stats(cmd);
  } else if (strcmp("calculate", cmd) == 0 || strcmp("c", cmd) == 0){
    printf("calculate what?\n");
  } else if (strcmp("calculate ", cmd) < -26 || strcmp("c ", cmd) < -26){
    if(curr_file == NULL){
      printf("must be working in a file first\n");
      return 0;
    }
    calculate(cmd);
  } else {
    printf("command \"%s\" not found, try 'help' or '?'\n",cmd);
  }
  return 0;
}
Example #10
0
int main(){
	const int nrows = 12;
	int nlist[nrows] = {1, 2, 4, 
		       8, 16, 24, 
		       32, 40, 60, 
		       1000, 10*1000, 100*1000};
	const char *rows[nrows] =  {"1", "2", "4", 
				    "8", "16", "24", 
				    "32", "40", "60", 
				    "1000", "10*1000", "100*1000"};
	const int ncols = 3;
	const char *cols[ncols] = {"min", "median", "max"};
	
	double cyc2dram[nrows*ncols];
	StatVector stats(NTRIALS);
	
	for(int i=0; i < nrows; i++){
		measure_latency(nlist[i], stats);
		cyc2dram[i+0*nrows] = stats.min();
		cyc2dram[i+1*nrows] = stats.median();
		cyc2dram[i+2*nrows] = stats.max();
	}
	
	verify_dir("DBG");
#ifdef MEMWALK
	const char* fname = "DBG/latency_memwalk.txt";
#else
	const char* fname = "DBG/latency_clflush.txt";
#endif
	link_cout(fname);

	Table tbl;
	tbl.dim(nrows, ncols);
	tbl.rows(rows);
	tbl.cols(cols);
	tbl.data(cyc2dram);
	char banner[200];
	sprintf(banner, "cycles to dram, ntrials = %d, when N pages accessed",
		NTRIALS);
	tbl.print(banner);
	
	unlink_cout();
}
Example #11
0
int main(){	
	//Add snakes and ladders to gameBoard array
	initGameBoard();
	//Initilise Seed
	time_t t;
	srand((unsigned)time(&t));

	//Play Game 1000000 time
	for (int k = 0; k < repetitions; k++){
		playGame();
	};
	//Generate statistics for the game
	stats();
	//Print results to file
	checkPRNG();
	print();

	return 0;
};
void SequenceNumberStatsTests::resyncTest() {

    SequenceNumberStats stats(0);

    quint16 sequence;

    sequence = 89;
    stats.sequenceNumberReceived(sequence);

    assert(stats.getUnreasonable() == 0);

    sequence = 2990;
    for (int i = 0; i < 10; i++) {
        stats.sequenceNumberReceived(sequence);
        sequence += (quint16)1;
    }

    assert(stats.getUnreasonable() == 0);


    sequence = 0;
    for (int R = 0; R < 7; R++) {
        stats.sequenceNumberReceived(sequence);
        sequence += (quint16)1;
    }

    assert(stats.getUnreasonable() == 7);

    sequence = 6000;
    for (int R = 0; R < 7; R++) {
        stats.sequenceNumberReceived(sequence);
        sequence += (quint16)1;
    }

    assert(stats.getUnreasonable() == 14);

    sequence = 9000;
    for (int i = 0; i < 10; i++) {
        stats.sequenceNumberReceived(sequence);
        sequence += (quint16)1;
    }
    assert(stats.getUnreasonable() == 0);
}
void fast4_arg_process(const char *args) {
    if (!args) return;
    char *input = bu_strdup(args);
    char **argv = (char **)bu_calloc(strlen(args) + 1, sizeof(char *), "argv array");
    int argc = bu_argv_from_string(argv, strlen(args), input);

    option::Stats stats(Fast4Usage, argc, argv);
    option::Option *options = (option::Option *)bu_calloc(stats.options_max, sizeof(option::Option), "options");
    option::Option *buffer= (option::Option *)bu_calloc(stats.buffer_max, sizeof(option::Option), "options");
    option::Parser parse(Fast4Usage, argc, argv, options, buffer);

    if (options[FAST4_WARN_DEFAULT_NAMES]) {
	bu_log("FASTGEN 4 opt: %s:%s\n", options[FAST4_WARN_DEFAULT_NAMES].name, options[FAST4_WARN_DEFAULT_NAMES].arg);
    }

    bu_free(input, "input");
    bu_free(options, "free options");
    bu_free(buffer, "free buffer");
}
Example #14
0
stats calculate_stats(int category, std::string save_id)
{
	DBG_NG << "calculate_stats, category: " << category << " side: " << save_id << " master_stats.size: " << master_stats.size() << "\n";
	if(category == 0) {
		stats res;
		// We are going from last to first to include correct turn stats in result
		for(int i = int(master_stats.size()); i > 0 ; --i) {
			merge_stats(res,calculate_stats(i,save_id));
		}

		return res;
	} else {
		const size_t index = master_stats.size() - size_t(category);
		if(index < master_stats.size() && master_stats[index].team_stats.find(save_id) != master_stats[index].team_stats.end()) {
			return master_stats[index].team_stats[save_id];
		} else {
			return stats();
		}
	}
}
Example #15
0
int main() {
    double a, b, c;
    unsigned d[] = {1, 22, 3, 44, 5, 1};
    double e[] = {1.1, 2.2, 3.3};
    char* s = "Jack and Jill.";
    
    printf("%lf\n", boxArea(3, 3, 3));

    stats(&a, &b, &c, 7, 2, 3);
    printf("%lf %lf %lf\n", a, b, c);
    
    printf("%lf\n", aveOdd(d, 6));
    
    reverse(e, e + 3);
    printf("%lf %lf %lf\n", e[0], e[1], e[2]);
    
    printf("%u\n", howMany('J', s));
    
    return 0;
}
Example #16
0
static void
msg_rtrashed( int sts, int uid, copy_vars_t *vars )
{
	SVARS_CHECK_CANCEL_RET;
	(void)uid;
	switch (sts) {
	case SYNC_OK:
	case SYNC_NOGOOD: /* the message is gone or heavily busted */
		break;
	default:
		cancel_sync( svars );
		free( vars );
		return;
	}
	free( vars );
	t ^= 1;
	svars->trash_done[t]++;
	stats( svars );
	sync_close( svars, t );
}
Example #17
0
void enter(gender g)
{
	while(1)
	{
		pthread_mutex_lock(&doorsign);

		if (occupancy == 0 || occupant == g)
		{
			occupancy++;
			occupant = g;

			stats(g);

			pthread_mutex_unlock(&doorsign);
			return;
		}

		pthread_mutex_unlock(&doorsign);
	}
}
    virtual int init(
        int argc,
        char *argv[]
    )
    {
        sum = 0;
        adds = 0;
        subs = 0;
        nbTX = 0;

        option::Stats  stats(usageDescriptor, argc, argv);
        option::Option *buffer  = new option::Option[stats.buffer_max];
        option::Option *options = new option::Option[stats.options_max];
        option::Parser parse(usageDescriptor, argc, argv, options, buffer);
        if(parse.error()) exit(1);

        delete [] options;
        delete [] buffer;
        return 0;
    }
Example #19
0
main(){
   while (4 == scanf("%d%*s%*s%lf%*s%d%d",&top,&score,&batch,&rel)) {
      if (top != oldtop) doit();
      if (batch == 100) b = 1;
      else if (batch == 1000) b = 2;
      else if (batch == 10000) b = 3;
      else if (batch == 1000000) b = 4;
      else printf("oops\n");
      Rel[b][rel]++;
      n++;
      estrel += score;
      Estrel[n] = estrel;
      stats();
//printf("rels %lg nrels %lg\n",rels, nrels);
      Rels[n] = rels;
      Nrels[n] = nrels;
      auc += (Nrels[n]-Nrels[n-1])*Rels[n-1];
   }
   doit();
}
void report_stats(ReceiveStats *data_obj, uint64_t rx_nsec)
{
  if (rx_nsec - data_obj->last_report_nsec >= REPORT_INTERVAL*SEC_TO_NSEC) {
    bool reported = false;

    for (auto& i : data_obj->stats) {
      std::string topic(i.first);
      PerTopicStats& stats(i.second);

      if (stats.transport_time_stats.isValid() &&
	  stats.interval_stats.isValid() &&
	  stats.size_stats.isValid()) {
	reported = true;

	std::cout << "Topic " << topic << std::endl;

	std::cout << "  Received " << stats.interval_stats.getCount()
		  << " messages at a rate of " << 1.0/stats.interval_stats.getMean()
		  << " Hz, with mean payload of " << stats.size_stats.getMean()
		  << " bytes, " << stats.size_stats.getSum()/stats.interval_stats.getSum()*1e-6
		  << " Mbytes/sec"
		  << std::endl;
	std::cout << "  Transport delay is " << stats.transport_time_stats.getMean()
		  << " +- " << stats.transport_time_stats.getStandardDeviation()
		  << " ms (" << stats.transport_time_stats.getMin()
		  << " .. " << stats.transport_time_stats.getMax()
		  << ")"
		  << std::endl;
	
	stats.interval_stats.clear();
	stats.transport_time_stats.clear();
	stats.size_stats.clear();
      }
    }

    if (reported) {
      data_obj->last_report_nsec = rx_nsec;
      std::cout << std::endl;
    }
  }
}
// get a sub process to collect the samples, main restarts us as needed
void dostats(FILE *quicklog, FILE* mainlog) {
	Vtraf_stat_samples samples, quicksamples;
	livestats stats(LIVE_LOGFILE_NAME);
	livestats quickstats(QUICK_LOGFILE_NAME);


	(void)collect_a_sample(samples,false,true);
	// and a truncated report - no smoothtraffic rules 
	(void)collect_a_sample(quicksamples, true, true);

	while(!time_to_go) {  
		sleep(2);
		reltimes times; // fresh timestamp set each loop...
		timestamp keep;
		// keep the number of samples under control
		if(!(times.now.t.tv_sec % FULL_SAMPLE_DELAY)) {
			// syslog(LOG_WARNING,"traffic full %d second sample", FULL_SAMPLE_DELAY);
			// full sample interval  
			keep = times.now;
			keep.t.tv_sec -= (FULL_SAMPLE_DELAY * 3); 
			truncate_sample_set(samples, keep);
			// take differences between last 2 samples to refresh our running totals
			stats.refresh_stats(samples, times);
			// and save those totals out
			stats.save(mainlog, times);
			(void)collect_a_sample(samples, false,true); 
		}
		else {
			// quick samples 
			// syslog(LOG_WARNING,"traffic 2 second sample");
			keep = times.now;
			keep.t.tv_sec -= 5; 
			truncate_sample_set(quicksamples, keep);
			// take differences between last 2 samples to refresh our running totals
			quickstats.refresh_stats(quicksamples, times);
			// and save those totals out
			quickstats.save(quicklog, times);
			(void)collect_a_sample(quicksamples, true, true);
		}
	}
}
Example #22
0
void Heap::dumpHeapStatistics(int level) {
    bool collect_cls_stats = (level >= 1);
    bool collect_hcls_stats = (level >= 1);

    threading::GLPromoteRegion _lock;

    fprintf(stderr, "\nCollecting heap stats for pid %d...\n", getpid());

    HeapStatistics stats(collect_cls_stats, collect_hcls_stats);

    small_arena.getStatistics(&stats);
    large_arena.getStatistics(&stats);
    huge_arena.getStatistics(&stats);

    stats.python.print("python");
    stats.conservative.print("conservative");
    stats.conservative_python.print("conservative_python");
    stats.untracked.print("untracked");
    stats.hcls.print("hcls");
    stats.precise.print("precise");

    if (collect_cls_stats) {
        for (const auto& p : stats.by_cls) {
            p.second.print(getFullNameOfClass(p.first).c_str());
        }
    }

    stats.total.print("Total");

    if (collect_hcls_stats) {
        fprintf(stderr, "%ld hidden classes currently alive\n", stats.hcls.nallocs);
        fprintf(stderr, "%ld have at least one Box that uses them\n", stats.hcls_uses.size());

        for (int i = 0; i <= HCLS_ATTRS_STAT_MAX; i++) {
            fprintf(stderr, "With % 3d attributes: %d\n", i, stats.num_hcls_by_attrs[i]);
        }
        fprintf(stderr, "With >% 2d attributes: %d\n", HCLS_ATTRS_STAT_MAX, stats.num_hcls_by_attrs_exceed);
    }

    fprintf(stderr, "\n");
}
Example #23
0
int main(void) {
   Count c = create_Count();
   next(c,1);
   next(c,2);
   next(c,1);
   next(c,3);
   next(c,7);
   next(c,1);
   next(c,2);
   next(c,3);
   next(c,1);
   next(c,1);                           
   assert(total(c) == 10);
   assert(unique(c) == 4);
   assert(count(c,1) == 5);
   assert(count(c,6) == 0);
   assert(count(c,7) == 1);
   assert(mostfreq(c) == 1);
   stats(c);
   destroy_Count(c);
}
Example #24
0
int main(int argc, char **argv) {
    setup();

    /* Start off with something obscene */
    switch_tests(220000 / 60);
    start = time(NULL);

    for(;;) {
        if (check_start())
            break;

        printf(" \r");
        do_frame();
        running_stats();
        check_switch();
    }

    stats();

    return 0;
}
Example #25
0
int main()
{
  double lambda = 8./6;
  double m = 2;
  short numberOfWorker = 1;
  PacketGenerator packGen = PacketGenerator(lambda,Priority::LOW);
  std::vector<PacketGenerator> vecPackGen {packGen};
  std::vector<Worker> vecWorker{};
  for(short index = 0; index < numberOfWorker;++index)
    {
      vecWorker.emplace_back(m);
    }
  std::function<bool(Packet&, Packet&)> earlierFun = earlier;
  std::function<short(std::vector<Worker>&,Packet&)> which = whichFree;
  DistributedSimulation sim(vecPackGen,vecWorker,false,0,earlierFun,which,0,0.00001);
  sim.run();

  ErlangC stats(lambda,m,numberOfWorker);
  stats.printStatistics();
  return 0;
}
Example #26
0
void run_exp_predicting_test(bool& ok) {
	test_tool t("test/digits/exp_predicting", ok);

	typedef recognition_problem p;

	reexp::lang<p> lang;
	reexp::data<p> data(lang, sample_dim());
	setup_reg<p>(lang, data);

	reexp::stats<p> stats(data);

	lang.add_exp(lang.rel(relid::up_down), 3);
	t<<"exp added."<<checkl<<checkl;
	lang.add_exp(lang.rel(relid::left_right), 3);
	t<<"exp added."<<checkl<<checkl;

/*	lang.add_exp(lang.rel(relid::left_right), 3);
	t<<"exp added."<<checkl<<checkl;*/

	print_prediction<p>(t, stats);
}
Example #27
0
void run_learn_picked_predict_test(bool& ok) {
	test_tool t("test/digits/learn_picked_predict", ok);

	typedef recognition_problem p;

	reexp::lang<p> lang;
	reexp::data<p> data(lang, sample_dim());
	setup_reg<p>(lang, data);

	reexp::stats<p> stats(data);


	float before = stats.ndl();
	lang.add_exp(lang.rel(relid::up_down), 3);
	float after = stats.ndl();
	t<<"info "<<before<<" -> "<<after<<checkl<<checkl;
	before = after;
	lang.add_exp(lang.rel(relid::left_right), 3);
	after = stats.ndl();
	t<<"info "<<before<<" -> "<<after<<checkl<<checkl;

	t<<checkl<<"learning done."<<checkl<<checkl;

	print_scan(t, lang, stats);

	reexp::pinfo info;
	setup_pinfo(info);
	reexp::lang_info<p> li(info, lang);

	t<<"vars:\n\n"<<li.drawn_vars_tostring(cvarid::x, cvarid::y);

	t<<"px"<<checkl<<checkl;
	print_pixels(t, data.var(varid::pixel));
	for (int i = 0; i < 1; i++) {
		t<<"exp"<<i<<checkl<<checkl;
		print_pixels(t, data.var(varid::digit9 + i + 1));
	}

	print_prediction<p>(t, stats);
}
Example #28
0
static void bench(SkPMColor* scratch, SkPicture& src, const char* name) {
    SkAutoTUnref<SkPicture> picture(rerecord_with_tilegrid(src));
    SkAutoTDelete<EXPERIMENTAL::SkPlayback> record(rerecord_with_skr(src));

    SkAutoTDelete<SkCanvas> canvas(SkCanvas::NewRasterDirectN32(src.width(),
                                                                src.height(),
                                                                scratch,
                                                                src.width() * sizeof(SkPMColor)));
    canvas->clipRect(SkRect::MakeWH(SkIntToScalar(FLAGS_tile), SkIntToScalar(FLAGS_tile)));

    // Draw once to warm any caches.  The first sample otherwise can be very noisy.
    draw(*record, *picture, canvas.get());

    WallTimer timer;
    const double scale = timescale();
    SkAutoTMalloc<double> samples(FLAGS_samples);
    for (int i = 0; i < FLAGS_samples; i++) {
        // We assume timer overhead (typically, ~30ns) is insignificant
        // compared to draw runtime (at least ~100us, usually several ms).
        timer.start();
        draw(*record, *picture, canvas.get());
        timer.end();
        samples[i] = timer.fWall * scale;
    }

    Stats stats(samples.get(), FLAGS_samples);
    if (FLAGS_verbose == 0) {
        printf("%g\t%s\n", stats.min, name);
    } else if (FLAGS_verbose == 1) {
        // Get a rough idea of how noisy the measurements were.
        const double noisePercent = 100 * sqrt(stats.var) / stats.mean;
        printf("%g\t%g\t%g\t±%.0f%%\t%s\n", stats.min, stats.mean, stats.max, noisePercent, name);
    } else if (FLAGS_verbose == 2) {
        printf("%s", name);
        for (int i = 0; i < FLAGS_samples; i++) {
            printf("\t%g", samples[i]);
        }
        printf("\n");
    }
}
Example #29
0
//! dump stats if enabled and exit
void pose::prepExit(void) 
{
#ifndef CMK_OPTIMIZE
  if(pose_config.stats)
    {
      CProxy_localStat stats(theLocalStats);
      CkPrintf("%d PE Simulation finished at %f. Gathering stats...\n", 
	       CkNumPes(), CmiWallTimer() - sim_timer);
      stats.SendStats();
    }
  else
    {
      CkPrintf("%d PE Simulation finished at %f.\n", CkNumPes(), 
	       CmiWallTimer() - sim_timer);
      POSE_exit();
    }
#else
  CkPrintf("%d PE Simulation finished at %f.\n", CkNumPes(), 
	   CmiWallTimer() - sim_timer);
  POSE_exit();
#endif  
}
Example #30
0
void McrouterLogger::log() {
  std::vector<stat_t> stats(num_stats);
  prepare_stats(router_, stats.data());

  for (int i = 0; i < num_stats; ++i) {
    if (stats[i].group & rate_stats) {
      stats[i].type = stat_double;
      stats[i].data.dbl = stats_aggregate_rate_value(router_, i);
    }
  }

  write_stats_to_disk(router_.opts(), stats);
  write_config_sources_info_to_disk(router_);

  for (const auto& filepath : touchStatsFilepaths_) {
    touchFile(filepath);
  }

  if (additionalLogger_) {
    additionalLogger_->log(stats);
  }
}