Beispiel #1
0
Image<unsigned char>* Image<Type>::scaled2()
{
	Image<unsigned char> *img2 = new Image<unsigned char>(num_of_channels, height / 2, width / 2);
	//img2 = new Image<unsigned char>(num_of_channels, height / 2, width / 2);
	
	unsigned int x, y, x2, y2;
	unsigned char p, q;
	
	for (y = 0; y < img2->getHeight(); y++) 
	{
		y2 = 2 * y;
		for (x = 0; x < img2->getWidth(); x++)
		{
			x2 = 2 * x;
			for(unsigned int ch = 0; ch < num_of_channels; ch++)
			{
				p = AVERAGE((unsigned char)image[y2 * width * num_of_channels + x2 * num_of_channels + ch], (unsigned char)image[y2 * width * num_of_channels + (x2 + 1) * num_of_channels + ch]);
				q = AVERAGE((unsigned char)image[(y2 + 1) * width * num_of_channels + x2 * num_of_channels + ch], (unsigned char)image[(y2 + 1) * width * num_of_channels + (x2 + 1) * num_of_channels + ch]);
				img2->getImage()[y * img2->getWidth() * num_of_channels + x * num_of_channels + ch] = AVERAGE(p, q);
				//printf("%d ", AVERAGE(p, q));
			}
		} 
		//printf("\n");
	} 

	return img2;
}
Beispiel #2
0
void run_stats::debug_dump(void)
{
    benchmark_debug_log("run_stats: start_time={%u,%u} end_time={%u,%u}\n",
        m_start_time.tv_sec, m_start_time.tv_usec,
        m_end_time.tv_sec, m_end_time.tv_usec);
    
    for (std::vector<one_second_stats>::iterator i = m_stats.begin();
            i != m_stats.end(); i++) {

        benchmark_debug_log("  %u: get latency=%u.%ums, set latency=%u.%ums, wait latency=%u.%ums"
                            "m_ops_set/get/wait=%u/%u/%u, m_bytes_set/get=%u/%u, m_get_hit/miss=%u/%u\n",
            i->m_second,
            USEC_FORMAT(AVERAGE(i->m_total_get_latency, i->m_ops_get)),
            USEC_FORMAT(AVERAGE(i->m_total_set_latency, i->m_ops_set)),
            USEC_FORMAT(AVERAGE(i->m_total_wait_latency, i->m_ops_wait)),
            i->m_ops_set,
            i->m_ops_get,
            i->m_ops_wait,
            i->m_bytes_set,
            i->m_bytes_get,
            i->m_get_hits,
            i->m_get_misses);
    }


    for( latency_map_itr it = m_get_latency_map.begin() ; it != m_get_latency_map.end() ; it++) {
        if (it->second)
            benchmark_debug_log("  GET <= %u msec: %u\n", it->first, it->second);
    }
    for(  latency_map_itr it = m_set_latency_map.begin() ; it != m_set_latency_map.end() ; it++) {
        if (it->second)
            benchmark_debug_log("  SET <= %u msec: %u\n", it->first, it->second);
    }
    for(  latency_map_itr it = m_wait_latency_map.begin() ; it != m_wait_latency_map.end() ; it++) {
        if (it->second)
            benchmark_debug_log("  WAIT <= %u msec: %u\n", it->first, it->second);
    }
}
Beispiel #3
0
bool run_stats::save_csv(const char *filename)
{
    FILE *f = fopen(filename, "w");
    if (!f) {
        perror(filename);
        return false;
    }

    fprintf(f, "Per-Second Benchmark Data\n");
    fprintf(f, "Second,SET Requests,SET Average Latency,SET Total Bytes,"
               "GET Requests,GET Average Latency,GET Total Bytes,GET Misses, GET Hits,"
               "WAIT Requests,WAIT Average Latency\n");

    unsigned long int total_get_ops = 0;
    unsigned long int total_set_ops = 0;
    unsigned long int total_wait_ops = 0;

    for (std::vector<one_second_stats>::iterator i = m_stats.begin();
            i != m_stats.end(); i++) {

        fprintf(f, "%u,%lu,%u.%06u,%lu,%lu,%u.%06u,%lu,%u,%u,%lu,%u.%06u\n",
            i->m_second,
            i->m_ops_set,
            USEC_FORMAT(AVERAGE(i->m_total_set_latency, i->m_ops_set)),
            i->m_bytes_set,
            i->m_ops_get,
            USEC_FORMAT(AVERAGE(i->m_total_get_latency, i->m_ops_get)),
            i->m_bytes_get,
            i->m_get_misses,
            i->m_get_hits,
            i->m_ops_wait,
            USEC_FORMAT(AVERAGE(i->m_total_wait_latency, i->m_ops_wait)));

        total_get_ops += i->m_ops_get;
        total_set_ops += i->m_ops_set;
        total_wait_ops += i->m_ops_wait;
    }


    double total_count_float = 0;
    fprintf(f, "\n" "Full-Test GET Latency\n");
    fprintf(f, "Latency (<= msec),Percent\n");
    for ( latency_map_itr it = m_get_latency_map.begin() ; it != m_get_latency_map.end() ; it++ ) {
        total_count_float += it->second;
        fprintf(f, "%8.3f,%.2f\n", it->first, total_count_float / total_get_ops * 100);
    }

    total_count_float = 0;
    fprintf(f, "\n" "Full-Test SET Latency\n");
    fprintf(f, "Latency (<= msec),Percent\n");
    for ( latency_map_itr it = m_set_latency_map.begin(); it != m_set_latency_map.end() ; it++ ) {
        total_count_float += it->second;
        fprintf(f, "%8.3f,%.2f\n", it->first, total_count_float / total_set_ops * 100);
    }

    total_count_float = 0;
    fprintf(f, "\n" "Full-Test WAIT Latency\n");
    fprintf(f, "Latency (<= msec),Percent\n");
    for ( latency_map_itr it = m_wait_latency_map.begin(); it != m_wait_latency_map.end() ; it++ ) {
        total_count_float += it->second;
        fprintf(f, "%8.3f,%.2f\n", it->first, total_count_float / total_wait_ops * 100);
    }

    fclose(f);
    return true;
}