void calibrate_handle_final(Measurement m) {
	// store the measurement
	// check if same weight already exists and average both if it does
	Measurement *mf = NULL;
	for (int i = 0; i < calibrations_count; i++) {
		if (calibrations[i].weight != weight)
			continue;
		mf = &calibrations[i];
		mf->amp = (mf->amp + m.amp) / 2;
		mf->freq = (mf->freq + m.freq) / 2;
		mf->confidence = (mf->confidence + m.confidence) / 2;
		break;
	}
	if (mf == NULL) {
		m.weight = weight;
		calibrations[calibrations_count++] = m;
	}
	// store
	calibrations_save();
	
	// stop measuring and update layers
	stop_measure();
	layer_mark_dirty(text_layer);
	layer_mark_dirty(graph_layer);

	// vibrate to let the user know
	vibes_short_pulse();
}
static void calibrate_click_handler_select(ClickRecognizerRef recognizer, void *context) {
	if (is_measuring())
		stop_measure();
	else
		start_measure((MeasureHandler) calibrate_handle_measure, (FinalMeasureHandler) calibrate_handle_final);
	layer_mark_dirty(icon_layer);
}
Exemplo n.º 3
0
void stress() {
  int i;
  configure_all_pc("label1");
  start_measure("label1");
  while(i < 100000000) {
    sqrt(rand());
    i++;
  }
  stop_measure("label1");
}
Exemplo n.º 4
0
void run_tests()
{
	int i = 0, d = 0, k = 0;				
	//int cpus = 0;
 	int ncpus;
	state* s;
	get_init_state = get_init_stateI;
	get_moves_for_game_state = get_moves_for_game_stateI;
	get_state_for_move_and_game_state = get_state_for_move_and_game_stateI;
	evaluate_game_state = evaluate_game_stateI;
	free_state = free_stateI;
	free_moves = free_movesI;
	size_move = size_moveI;
	ncpus = sysconf(_SC_NPROCESSORS_ONLN);
	if(ncpus == -1)
		ncpus = 2;
	
	s = init_game();
	printf("#ncpus %d\n", ncpus);
	printf("avg_seconds avg_num_exp avg_num_disc avg_num_evaluated avg_num_seen avg_branch_factor avg_num_theory avg_percent_seen\n");
	for(d = 3; d < 7; d++)
	{
		max_depth = d;			
		printf("#depth %d\n", max_depth);
		for(i = 0; i < ncpus; i++)
		{
			num_threads = i+1;
			printf("#threads %d\n", num_threads);	
			double num_theory = 0.0;
			avg_seconds = 0.0;
			avg_num_exp = 0.0;
			avg_num_disc = 0.0;
			avg_seconds = 0.0;
			avg_num_exp = 0.0;
			avg_num_disc = 0.0;
			avg_num_evaluated = 0.0;
			avg_num_seen = 0.0;
			avg_branch_factor = 0.0;
			num_theory = 0.0;
			avg_num_theory = 0.0;
			avg_percent_seen = 0.0;

			for(k = 0; k < STAB; k++)
			{
				//display_board(stdout, 0, s);	
				//i
				
				start_measure();
				move* m = (move*)think((void*)s);
				stop_measure();
				//print_measure();
				free(m);
				avg_seconds += FSTAB*(((double)total.tv_sec) + (((double)total.tv_usec)/1000000.0));
				avg_num_exp += FSTAB*((double)num_nodes_expanded);
				avg_num_disc += FSTAB*((double)num_nodes_discarded);
				avg_num_evaluated += FSTAB*((double)num_nodes_evaluated);
				avg_num_seen += FSTAB*((double)num_nodes_seen);
				avg_branch_factor += FSTAB*((double)branching_factor);
				num_theory = pow(branching_factor, (double)d);
				avg_num_theory += FSTAB*((double)num_theory); 
				avg_percent_seen += FSTAB*(((double)num_nodes_seen)/(num_theory));
			}
		
			printf("%f %f %f %f %f %f %f %f\n", avg_seconds, avg_num_exp, avg_num_disc, avg_num_evaluated, avg_num_seen, avg_branch_factor, avg_num_theory, avg_percent_seen);
		}
	}
	free(s);
}
static void calibrate_window_unload(Window *window) {
	stop_measure();
	layer_destroy(text_layer);
	layer_destroy(graph_layer);
	layer_destroy(icon_layer);
}
Exemplo n.º 6
0
void stop_show_measure(id_proto) {
	stop_measure(id_pass);
	show_measure(id_pass);
}