Esempio n. 1
0
void summary(void) {
	printf("\n");
	printf(MSG_CP_SML, msgcnt[E_NEWLINE]);
	printf(MSG_CP_RCO, msgcnt[E_RESCOMP]);
	printf(MSG_CP_RCC, msgcnt[E_RESNEW]);
	printf(MSG_CP_SME, summarize(error_message_count()));
	printf(MSG_CP_SMW, summarize(msgcnt[E_WARN]));
}
Esempio n. 2
0
///////////////////////////////////////////////////////////////////////////////
// compareOne:  Compare results for a single test case
///////////////////////////////////////////////////////////////////////////////
void
ExactRGBATest::compareOne(ExactRGBAResult& oldR, ExactRGBAResult& newR) {
	if (oldR.skipped || newR.skipped) {
		env->log << name
			 << ((oldR.skipped && newR.skipped)? ":  SAME "
			 	: ":  DIFF ")
			 << newR.config->conciseDescription()
			 << '\n';
		if (oldR.skipped)
			 env->log << "\t"
				  << env->options.db1Name
				  << " skipped\n";
		if (newR.skipped)
			 env->log << "\t"
				  << env->options.db2Name
				  << " skipped\n";
		env->log << "\tNo comparison is possible.\n";
		return;
	}

	if (oldR.ub == newR.ub && oldR.us == newR.us && oldR.ui == newR.ui) {
		if (env->options.verbosity)
			env->log << name
				 << ":  SAME "
				 << newR.config->conciseDescription()
				 << '\n'
				 << (oldR.pass
				     ? "\tBoth PASS\n"
				     : "\tBoth FAIL\n");
	} else {
		env->log << name
			 << ":  DIFF "
			 << newR.config->conciseDescription()
			 << '\n'
#if 1
			 << '\t'
			 << env->options.db1Name
			 << (oldR.pass? " PASS, ": " FAIL, ")
			 << env->options.db2Name
			 << (newR.pass? " PASS\n": " FAIL\n");
#endif
			 ;
	}

	summarize("Unsigned byte:   ", oldR.ub, newR.ub);
	summarize("Unsigned short:  ", oldR.us, newR.us);
	summarize("Unsigned int:    ", oldR.ui, newR.ui);
} // ExactRGBATest::compareOne
Esempio n. 3
0
int main(int argc, const char *argv[])
{
    fit_summary *summary;
    int i;

    /* Check arguments */
    if (argc < 2) {
        printf("Usage: %s FIT-FILE\n", argv[0]);
        return EXIT_SUCCESS;
    }

    for (i = 1; i < argc; i++) {
        iprintf("Activity: %s\n", argv[i]);
        print_increase_indent();

        summary = summarize(argv[i]);

        if (summary) {
            print_summary(summary);
            // print_record_table(summary);
            destroy_summary(summary);
        }

        print_decrease_indent();
    }

    return EXIT_SUCCESS;
}
Esempio n. 4
0
int main(int argc, char *argv[]) {
  float hertz = argc > 1 ? atof(argv[1]) : 440.0f;

  // AVOID_DENORMALS;

  for (int spd = OSC8K; spd <= OSC192K; spd += 1)
    oscillator_init(&osc[spd], hertz, 0.0f, speed[spd]);

  int trun = 60*60;		/* one hour */
  int tsmp = 60;		/* one minute */
  
  for (;;) {
    for (int spd = OSC8K; spd <= OSC192K; spd += 1) {
      int nrun = trun * speed[spd];
      int nsmp = tsmp * speed[spd];
      for (int j = 0; j < nrun-nsmp; j += 1) {
	float z = oscillator_process(&osc[spd]);
      }
      for (int j = 0; j < nsmp; j += 1) {
	test(spd, oscillator_process(&osc[spd]), hertz, speed[spd]);
      }
      res[spd].samples += nrun;
      summarize(spd);
      reset(spd);
    }
  }
  return 0;
}
Esempio n. 5
0
int time_main(int argc UNUSED_PARAM, char **argv)
{
	resource_t res;
	const char *output_format = default_format;
	int opt;

	opt_complementary = "-1"; /* at least one arg */
	/* "+": stop on first non-option */
	opt = getopt32(argv, "+vp");
	argv += optind;
	if (opt & 1)
		output_format = long_format;
	if (opt & 2)
		output_format = posix_format;

	run_command(argv, &res);

	/* Cheat. printf's are shorter :) */
	/* (but see bb_putchar() body for additional wrinkle!) */
	xdup2(2, 1); /* just in case libc does something silly :( */
	stdout = stderr;
	summarize(output_format, argv, &res);

	if (WIFSTOPPED(res.waitstatus))
		return WSTOPSIG(res.waitstatus);
	if (WIFSIGNALED(res.waitstatus))
		return WTERMSIG(res.waitstatus);
	if (WIFEXITED(res.waitstatus))
		return WEXITSTATUS(res.waitstatus);
	fflush_stdout_and_exit(EXIT_SUCCESS);
}
Esempio n. 6
0
map_t *
map_generate(uint64_t seed)
{
    map_t *map = malloc(sizeof(*map));
    size_t alloc_size = WORK_SIZE * WORK_SIZE * sizeof(float);
    float *buf_a = calloc(alloc_size, 1);
    float *buf_b = calloc(alloc_size, 1);
    float *heightmap = buf_a;
    for (int i = 0; i < 4; i++)
        heightmap[i] = rand_uniform_s(&seed, -1, 1);
    size_t size = 3;
    while (size < WORK_SIZE) {
        size = grow(buf_a, size, buf_b, &seed);
        heightmap = buf_b;
        buf_b = buf_a;
        buf_a = heightmap;
    }
    for (size_t y = 0; y < MAP_HEIGHT * MAP_HEIGHT; y++) {
        for (size_t x = 0; x < MAP_WIDTH * MAP_WIDTH; x++) {
            float height = heightmap[y * WORK_SIZE + x];
            float sx = x / (float)(MAP_WIDTH * MAP_WIDTH) - 0.5;
            float sy = y / (float)(MAP_HEIGHT * MAP_HEIGHT) - 0.5;
            float s = sqrt(sx * sx + sy * sy) * 3 - 0.45f;
            map->low[x][y].height = height - s;
        }
    }
    free(buf_a);
    free(buf_b);
    summarize(map, &seed);
    return map;
}
Esempio n. 7
0
void test(int t) {
	printf("Sending command to run TCP test %d to %zd clients\n", t, clients.size());

	completed_tests = 0;
	active_clients = clients.size();
	test_results = new test_result_t[active_clients];

	time_t test_start = time(NULL);

	vars[0].i = t;
	send_frame_to_all(NW_CMD_DOWNLOAD);

	while(active_clients > completed_tests) {
		read_all_clients(1);
	}
	time_t total_time = time(NULL)-test_start;
	int succ = 0;
	test_result_t res = summarize(succ);
	printf("Test suite completed. %d/%d clients succeded.\n", succ, active_clients);
	if(succ > 0) {
		float speed = res.filesize/total_time;
		printf("Total summarized speed: %.2fMbps\n", to_mbps(res.speed));
		printf("Total filesize %.2fMb\n", to_mbytes(res.filesize));
		printf("Total time %ld seconds \n", total_time);
		printf("Total calculated speed: %.2fMbps\n", to_mbps(speed));
	}
}
Esempio n. 8
0
static int stats_file_history_update(struct stats_file *data_file)
{
	struct stats_file _history_file, *history_file;
	struct stats_file _temp_file, *temp_file;
	int err;

	history_file = &_history_file;
	temp_file = &_temp_file;

	bzero(history_file, sizeof(struct stats_file));
	bzero(temp_file, sizeof(struct stats_file));

	err = stats_open(history_file, data_file->history_name);
	if (err < 0)
		return err;
	stats_file_setup(history_file);

	err = stats_open_temp(temp_file);
	if (err < 0) {
		stats_free(history_file);
		return err;
	}
	stats_file_setup(temp_file);

	summarize(data_file, history_file, temp_file);

	err = stats_file_close_swap(history_file, temp_file);

	return err;
}
Esempio n. 9
0
int time_main(int argc UNUSED_PARAM, char **argv)
{
	resource_t res;
	const char *output_format = default_format;
	int opt;

	opt_complementary = "-1"; /* at least one arg */
	/* "+": stop on first non-option */
	opt = getopt32(argv, "+vp");
	argv += optind;
	if (opt & 1)
		output_format = long_format;
	if (opt & 2)
		output_format = posix_format;

	run_command(argv, &res);

	/* Cheat. printf's are shorter :) */
	xdup2(STDERR_FILENO, STDOUT_FILENO);
	summarize(output_format, argv, &res);

	if (WIFSTOPPED(res.waitstatus))
		return WSTOPSIG(res.waitstatus);
	if (WIFSIGNALED(res.waitstatus))
		return WTERMSIG(res.waitstatus);
	if (WIFEXITED(res.waitstatus))
		return WEXITSTATUS(res.waitstatus);
	fflush_stdout_and_exit(EXIT_SUCCESS);
}
Esempio n. 10
0
media_auditor::summary media_auditor::audit_samples()
{
	// start fresh
	m_record_list.reset();

	int required = 0;
	int found = 0;

	// iterate over sample entries
	samples_device_iterator iterator(m_enumerator.config().root_device());
	for (samples_device *device = iterator.first(); device != nullptr; device = iterator.next())
	{
		// by default we just search using the driver name
		std::string searchpath(m_enumerator.driver().name);

		// add the alternate path if present
		samples_iterator iter(*device);
		if (iter.altbasename() != nullptr)
			searchpath.append(";").append(iter.altbasename());

		// iterate over samples in this entry
		for (const char *samplename = iter.first(); samplename != nullptr; samplename = iter.next())
		{
			required++;

			// create a new record
			audit_record &record = m_record_list.append(*global_alloc(audit_record(samplename, audit_record::MEDIA_SAMPLE)));

			// look for the files
			emu_file file(m_enumerator.options().sample_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
			path_iterator path(searchpath.c_str());
			std::string curpath;
			while (path.next(curpath, samplename))
			{
				// attempt to access the file (.flac) or (.wav)
				osd_file::error filerr = file.open(curpath.c_str(), ".flac");
				if (filerr != osd_file::error::NONE)
					filerr = file.open(curpath.c_str(), ".wav");

				if (filerr == osd_file::error::NONE)
				{
					record.set_status(audit_record::STATUS_GOOD, audit_record::SUBSTATUS_GOOD);
					found++;
				}
				else
					record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND);
			}
		}
	}

	if (found == 0 && required > 0)
	{
		m_record_list.reset();
		return NOTFOUND;
	}

	// return a summary
	return summarize(m_enumerator.driver().name);
}
Esempio n. 11
0
int main(int argc, char *argv[]) {
    int n = argc > 1 ? atoi(argv[1]) : 1000;
    float hertz = argc > 2 ? atof(argv[2]) : 440.0f;
    float radians = argc > 3 ? atof(argv[3]) : 0.0f;
    int sample_rate = argc > 4 ? atoi(argv[4]) : 96000;
    long int frame = 0;
    AVOID_DENORMALS;
    osc_fd_init(hertz, radians, sample_rate);
    osc_td_init(hertz, radians, sample_rate);
    osc_zd_init(hertz, radians, sample_rate);
    // osc_f_init(hertz, radians, sample_rate);
    // osc_t_init(hertz, radians, sample_rate);
    // osc_z_init(hertz, radians, sample_rate);
    while (1) {
        reset(0);
        reset(1);
        reset(2);
        // reset(3);
        // reset(4);
        // reset(5);
        for (int i = 0; i < n; i += 1) {
            test(0, osc_fd_process(), frame, hertz, sample_rate);
            test(1, osc_td_process(), frame, hertz, sample_rate);
            test(2, osc_zd_process(), frame, hertz, sample_rate);
            // test(3, osc_f_process(), frame, hertz, sample_rate);
            // test(4, osc_t_process(), frame, hertz, sample_rate);
            // test(5, osc_z_process(), frame, hertz, sample_rate);
            frame += 1;
        }
        time(0, osc_fd_process, n);
        time(1, osc_td_process, n);
        time(2, osc_zd_process, n);
        // time(3, osc_f_process, n);
        // time(4, osc_t_process, n);
        // time(5, osc_z_process, n);
        summarize(0);
        summarize(1);
        summarize(2);
        //summarize(3);
        //summarize(4);
        //summarize(5);
    }
    return 0;
}
Esempio n. 12
0
int main(int argc, const char **argv)
{
  if (argc != 1)
  {
    fprintf(stderr, "expected no arguments\n");
    return EXIT_FAILURE;
  }
  summarize(stdin, stdout);
  return EXIT_SUCCESS;
}
Esempio n. 13
0
	void PruningExpr::print(const char* name,
			Util::uint64 suc[][MAX_REC+1],
			Util::uint64 err[][MAX_REC+1]) {
		Log::expr << name << ",ave,dev,all,min,max\n";
		for (int dep = 0; dep <= MAX_DEP; dep++) {
			double average, deviation, all, max, min;
			summarize(suc[dep], err[dep], MAX_REC+1, average, deviation, all, max, min);
			Log::expr << dep << ',' << average << ',' << deviation << ',' << all << ',' << min << ',' << max << '\n';
		}
		Log::expr << '\n';
	}
Esempio n. 14
0
void
CrT_summarize(dbref player)
{
#if defined(HAVE_PTHREAD_H)
	LOCKCRT();
#endif
    summarize_player = player;
    summarize(summarize_notify);
#if defined(HAVE_PTHREAD_H)
	UNLOCKCRT();
#endif
}
Esempio n. 15
0
int main(int argc, char** argv) {
	
	// output command for documentation:
	int i;
	for (i = 0; i < argc; ++i)
		PRINTF("%s ", argv[i] );
	PRINTF("\n");

        PRINTF("dataDouble = %p, data32 = %p\n", &dataDouble, &data32);

	if (argc > 1) iterations = atoi(argv[1]);
	if (argc > 2) init_value = (double) atof(argv[2]);


// int32_t
	::fill(data32, data32+SIZE, int32_t(init_value));
	
	for_loop_tests<UnrollLimit, int32_t>::do_test( data32, "int32_t for loop unroll" );
	summarize("int32_t for loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );
	
	while_loop_tests<UnrollLimit, int32_t>::do_test( data32, "int32_t while loop unroll" );
	summarize("int32_t while loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );

	do_loop_tests<UnrollLimit, int32_t>::do_test( data32, "int32_t do loop unroll" );
	summarize("int32_t do loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );

	goto_loop_tests<UnrollLimit, int32_t>::do_test( data32, "int32_t goto loop unroll" );	
	summarize("int32_t goto loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );


// double
	iterations /= 4;

	::fill(dataDouble, dataDouble+SIZE, double(init_value));
	
	for_loop_tests<UnrollLimit, double>::do_test( dataDouble, "double for loop unroll" );
	summarize("double for loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );
	
	while_loop_tests<UnrollLimit, double>::do_test( dataDouble, "double while loop unroll" );
	summarize("double while loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );

	do_loop_tests<UnrollLimit, double>::do_test( dataDouble, "double do loop unroll" );
	summarize("double do loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );

	goto_loop_tests<UnrollLimit, double>::do_test( dataDouble, "double goto loop unroll" );	
	summarize("double goto loop unrolling", SIZE, iterations, kDontShowGMeans, kDontShowPenalty );


	return 0;
}
Esempio n. 16
0
/*
 * Compute the # bytes in a variable height, row-aligned strip.
 */
tsize_t
TIFFVStripSize(TIFF* tif, uint32 nrows)
{
	TIFFDirectory *td = &tif->tif_dir;

	if (nrows == (uint32) -1)
		nrows = td->td_imagelength;
	if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
	    td->td_photometric == PHOTOMETRIC_YCBCR &&
	    !isUpSampled(tif)) {
		/*
		 * Packed YCbCr data contain one Cb+Cr for every
		 * HorizontalSampling*VerticalSampling Y values.
		 * Must also roundup width and height when calculating
		 * since images that are not a multiple of the
		 * horizontal/vertical subsampling area include
		 * YCbCr data for the extended image.
		 */
                uint16 ycbcrsubsampling[2];
                tsize_t w, scanline, samplingarea;
		ycbcrsubsampling[0] = 0;
		ycbcrsubsampling[1] = 0;

                TIFFGetField( tif, TIFFTAG_YCBCRSUBSAMPLING, 
                              ycbcrsubsampling + 0, 
                              ycbcrsubsampling + 1 );
		/* make sure we dont get division by 0 due to bad tiffs */
		if (!ycbcrsubsampling[0]) ycbcrsubsampling[0] = 1;
		if (!ycbcrsubsampling[1]) ycbcrsubsampling[1] = 1;

		samplingarea = ycbcrsubsampling[0]*ycbcrsubsampling[1];
		if (samplingarea == 0) {
			_TIFFError(tif, tif->tif_name,
				"Invalid YCbCr subsampling");
			return 0;
		}

		w = TIFFroundup(td->td_imagewidth, ycbcrsubsampling[0]);
		scanline = TIFFhowmany8(multiply(tif, w, td->td_bitspersample,
						 "TIFFVStripSize"));
		nrows = TIFFroundup(nrows, ycbcrsubsampling[1]);
		/* NB: don't need TIFFhowmany here 'cuz everything is rounded */
		scanline = multiply(tif, nrows, scanline, "TIFFVStripSize");
		return ((tsize_t)
		    summarize(tif, scanline,
			      multiply(tif, 2, scanline / samplingarea,
				       "TIFFVStripSize"), "TIFFVStripSize"));
	} else
		return ((tsize_t) multiply(tif, nrows, TIFFScanlineSize(tif),
					   "TIFFVStripSize"));
}
Esempio n. 17
0
media_auditor::summary media_auditor::audit_device(device_t *device, const char *validation)
{
	// start fresh
	m_record_list.reset();

	// store validation for later
	m_validation = validation;
	m_searchpath = device->shortname();

	int found = 0;
	int required = 0;

	// now iterate over regions and ROMs within
	for (const rom_entry *region = rom_first_region(*device); region != nullptr; region = rom_next_region(region))
	{
		for (const rom_entry *rom = rom_first_file(region); rom; rom = rom_next_file(rom))
		{
			hash_collection hashes(ROM_GETHASHDATA(rom));

			// count the number of files with hashes
			if (!hashes.flag(hash_collection::FLAG_NO_DUMP) && !ROM_ISOPTIONAL(rom))
			{
				required++;
			}

			// audit a file
			audit_record *record = nullptr;
			if (ROMREGION_ISROMDATA(region))
				record = audit_one_rom(rom);

			// audit a disk
			else if (ROMREGION_ISDISKDATA(region))
				record = audit_one_disk(rom);

			// count the number of files that are found.
			if (record != nullptr && (record->status() == audit_record::STATUS_GOOD || record->status() == audit_record::STATUS_FOUND_INVALID))
			{
				found++;
			}
		}
	}

	if (found == 0 && required > 0)
	{
		m_record_list.reset();
		return NOTFOUND;
	}

	// return a summary
	return summarize(device->shortname());
}
Esempio n. 18
0
int main (int argc, char **argv) {
    init();
    if (parse_args(argc, argv) != 0) {
	hc_test_log(LOG_ERROR_LEVEL, "An error occurred while parsing the command line arguments.\n");
	return 2;
    }
    if (help_asked == TRUE) {
	usage();
	return 0;
    }
    load_tests();
    run();
    summarize();
    return 0;
}
Esempio n. 19
0
media_auditor::summary media_auditor::audit_samples()
{
	// start fresh
	m_record_list.reset();

	// iterate over sample entries
	for (const device_t *device = m_enumerator.config().first_device(); device != NULL; device = device->next())
		if (device->type() == SAMPLES)
		{
			const samples_interface *intf = reinterpret_cast<const samples_interface *>(device->static_config());
			if (intf->samplenames != NULL)
			{
				// by default we just search using the driver name
				astring searchpath(m_enumerator.driver().name);

				// iterate over samples in this entry
				for (int sampnum = 0; intf->samplenames[sampnum] != NULL; sampnum++)
				{
					// starred entries indicate an additional searchpath
					if (intf->samplenames[sampnum][0] == '*')
					{
						searchpath.cat(";").cat(&intf->samplenames[sampnum][1]);
						continue;
					}

					// create a new record
					audit_record &record = m_record_list.append(*global_alloc(audit_record(intf->samplenames[sampnum], audit_record::MEDIA_SAMPLE)));

					// look for the files
					emu_file file(m_enumerator.options().sample_path(), OPEN_FLAG_READ | OPEN_FLAG_NO_PRELOAD);
					path_iterator path(searchpath);
					astring curpath;
					while (path.next(curpath, intf->samplenames[sampnum]))
					{
						// attempt to access the file
						file_error filerr = file.open(curpath);
						if (filerr == FILERR_NONE)
							record.set_status(audit_record::STATUS_GOOD, audit_record::SUBSTATUS_GOOD);
						else
							record.set_status(audit_record::STATUS_NOT_FOUND, audit_record::SUBSTATUS_NOT_FOUND);
					}
				}
			}
		}

	// return a summary
	return summarize();
}
Esempio n. 20
0
/*
 * Each test is run in a private work dir.  Those work dirs
 * do have consistent and predictable names, in case a group
 * of tests need to collaborate.  However, there is no provision
 * for requiring that tests run in a certain order.
 */
static int test_run(int i, const char *tmpdir)
{
	int failures_before = failures;

	if (!quiet_flag) {
		printf("%d: %s\n", i, tests[i].name);
		fflush(stdout);
	}

	/*
	 * Always explicitly chdir() in case the last test moved us to
	 * a strange place.
	 */
	if (chdir(tmpdir)) {
		fprintf(stderr,
		    "ERROR: Couldn't chdir to temp dir %s\n",
		    tmpdir);
		exit(1);
	}
	/* Create a temp directory for this specific test. */
	if (mkdir(tests[i].name, 0755)) {
		fprintf(stderr,
		    "ERROR: Couldn't create temp dir ``%s''\n",
		    tests[i].name);
		exit(1);
	}
	/* Chdir() to that work directory. */
	if (chdir(tests[i].name)) {
		fprintf(stderr,
		    "ERROR: Couldn't chdir to temp dir ``%s''\n",
		    tests[i].name);
		exit(1);
	}
	/* Explicitly reset the locale before each test. */
	setlocale(LC_ALL, "C");
	/* Run the actual test. */
	(*tests[i].func)();
	/* Summarize the results of this test. */
	summarize();
	/* If there were no failures, we can remove the work dir. */
	if (failures == failures_before) {
		if (!keep_temp_files && chdir(tmpdir) == 0) {
			systemf("rm -rf %s", tests[i].name);
		}
	}
	/* Return appropriate status. */
	return (failures == failures_before ? 0 : 1);
}
Esempio n. 21
0
void
CrT_summarize_to_file(const char *file, const char *comment)
{
	if ((summarize_fd = fopen(file, "ab")) == 0)
		return;
	if (comment && *comment) {
		fprintf(summarize_fd, "%s\n", comment);
	} {
		time_t lt = time(NULL);

		fprintf(summarize_fd, "%s", ctime(&lt));
	}

	summarize(summarize_to_file);

	fclose(summarize_fd);
}
Esempio n. 22
0
int main(int argc, char **argv)
{
	int a;

	if(argc < 2)
	{
		printf("Usage: %s <mk6file>\n", argv[0]);

		exit(EXIT_SUCCESS);
	}

	for(a = 1; a < argc; ++a)
	{
		summarize(argv[a]);
	}

	return 0;
}
Esempio n. 23
0
int main(int argc, char **argv) {
	// Break the cipher text using three lowercase characters and XOR encryption, then add the ascii values of the original text
	unsigned char key[3];
	size_t len = sizeof(cipher_text)/sizeof(cipher_text[0]);
	char original[len + 1];

	for(key[0] = 'a'; key[0] <= 'z'; ++key[0]) {
		for(key[1] = 'a'; key[1] <= 'z'; ++key[1]) {
			for(key[2] = 'a'; key[2] <= 'z'; ++key[2]) {
				decrypt(key, 3, cipher_text, len, original);
				// Locate two command english words used in sentences
				if(strstr(original, " the ") && strstr(original, " a "))
					printf("%s\n\nSum is: %d\n", original, summarize(original));
			}
		}
	}
	return 0;
}
Esempio n. 24
0
/*
 * Compute the # bytes in a variable length, row-aligned tile.
 */
tsize_t
TIFFVTileSize(TIFF* tif, uint32 nrows)
{
	TIFFDirectory *td = &tif->tif_dir;
	tsize_t tilesize;

	if (td->td_tilelength == 0 || td->td_tilewidth == 0 ||
	    td->td_tiledepth == 0)
		return ((tsize_t) 0);
	if (td->td_planarconfig == PLANARCONFIG_CONTIG &&
	    td->td_photometric == PHOTOMETRIC_YCBCR &&
	    !isUpSampled(tif)) {
		/*
		 * Packed YCbCr data contain one Cb+Cr for every
		 * HorizontalSampling*VerticalSampling Y values.
		 * Must also roundup width and height when calculating
		 * since images that are not a multiple of the
		 * horizontal/vertical subsampling area include
		 * YCbCr data for the extended image.
		 */
		tsize_t w =
		    TIFFroundup(td->td_tilewidth, td->td_ycbcrsubsampling[0]);
		tsize_t rowsize =
		    TIFFhowmany8(multiply(tif, w, td->td_bitspersample,
					  "TIFFVTileSize"));
		tsize_t samplingarea =
		    td->td_ycbcrsubsampling[0]*td->td_ycbcrsubsampling[1];
		if (samplingarea == 0) {
			TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Invalid YCbCr subsampling");
			return 0;
		}
		nrows = TIFFroundup(nrows, td->td_ycbcrsubsampling[1]);
		/* NB: don't need TIFFhowmany here 'cuz everything is rounded */
		tilesize = multiply(tif, nrows, rowsize, "TIFFVTileSize");
		tilesize = summarize(tif, tilesize,
				     multiply(tif, 2, tilesize / samplingarea,
					      "TIFFVTileSize"),
				     "TIFFVTileSize");
	} else
		tilesize = multiply(tif, nrows, TIFFTileRowSize(tif),
				    "TIFFVTileSize");
	return ((tsize_t)
	    multiply(tif, tilesize, td->td_tiledepth, "TIFFVTileSize"));
}
Esempio n. 25
0
int time_main(int argc, char **argv)
{
	int gotone;
	resource_t res;
	const char *output_format = default_format;

	argc--;
	argv++;
	/* Parse any options  -- don't use getopt() here so we don't
	 * consume the args of our client application... */
	while (argc > 0 && **argv == '-') {
		gotone = 0;
		while (gotone == 0 && *++(*argv)) {
			switch (**argv) {
			case 'v':
				output_format = long_format;
				break;
			case 'p':
				output_format = posix_format;
				break;
			default:
				bb_show_usage();
			}
			argc--;
			argv++;
			gotone = 1;
		}
	}

	if (argv == NULL || *argv == NULL)
		bb_show_usage();

	run_command(argv, &res);
	summarize(stderr, output_format, argv, &res);
	fflush(stderr);

	if (WIFSTOPPED(res.waitstatus))
		exit(WSTOPSIG(res.waitstatus));
	else if (WIFSIGNALED(res.waitstatus))
		exit(WTERMSIG(res.waitstatus));
	else if (WIFEXITED(res.waitstatus))
		exit(WEXITSTATUS(res.waitstatus));
	return 0;
}
Esempio n. 26
0
int time_main(int argc, char **argv)
{
	resource_t res;
	const char *output_format = default_format;
	char c;

	goto next;
	/* Parse any options  -- don't use getopt() here so we don't
	 * consume the args of our client application... */
	while (argc > 0 && argv[0][0] == '-') {
		while ((c = *++*argv)) {
			switch (c) {
			case 'v':
				output_format = long_format;
				break;
			case 'p':
				output_format = posix_format;
				break;
			default:
				bb_show_usage();
			}
		}
 next:
		argv++;
		argc--;
		if (!argc)
			bb_show_usage();
	}

	run_command(argv, &res);

	/* Cheat. printf's are shorter :) */
	stdout = stderr;
	dup2(2, 1); /* just in case libc does something silly :( */
	summarize(output_format, argv, &res);

	if (WIFSTOPPED(res.waitstatus))
		return WSTOPSIG(res.waitstatus);
	if (WIFSIGNALED(res.waitstatus))
		return WTERMSIG(res.waitstatus);
	if (WIFEXITED(res.waitstatus))
		return WEXITSTATUS(res.waitstatus);
	fflush_stdout_and_exit(0);
}
Esempio n. 27
0
/*
 * Return the number of bytes to read/write in a call to
 * one of the scanline-oriented i/o routines.  Note that
 * this number may be 1/samples-per-pixel if data is
 * stored as separate planes.
 */
tsize_t
TIFFScanlineSize(TIFF* tif)
{
	TIFFDirectory *td = &tif->tif_dir;
	tsize_t scanline;

	if (td->td_planarconfig == PLANARCONFIG_CONTIG) {
		if (td->td_photometric == PHOTOMETRIC_YCBCR
		    && !isUpSampled(tif)) {
			uint16 ycbcrsubsampling[2];

			TIFFGetField(tif, TIFFTAG_YCBCRSUBSAMPLING,
				     ycbcrsubsampling + 0,
				     ycbcrsubsampling + 1);

			if (ycbcrsubsampling[0] == 0) {
				TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
					     "Invalid YCbCr subsampling");
				return 0;
			}

			scanline = TIFFroundup(td->td_imagewidth,
					       ycbcrsubsampling[0]);
			scanline = TIFFhowmany8(multiply(tif, scanline,
							 td->td_bitspersample,
							 "TIFFScanlineSize"));
			return ((tsize_t)
				summarize(tif, scanline,
					  multiply(tif, 2,
						scanline / ycbcrsubsampling[0],
						"TIFFVStripSize"),
					  "TIFFVStripSize"));
		} else {
			scanline = multiply(tif, td->td_imagewidth,
					    td->td_samplesperpixel,
					    "TIFFScanlineSize");
		}
	} else
		scanline = td->td_imagewidth;
	return ((tsize_t) TIFFhowmany8(multiply(tif, scanline,
						td->td_bitspersample,
						"TIFFScanlineSize")));
}
Esempio n. 28
0
void
CrT_summarize_to_file(const char *file, const char *comment)
{
    if ((summarize_fd = fopen(file, "ab")) == 0)
	return;
    if (comment && *comment) {
	fprintf(summarize_fd, "%s\n", comment);
    }
    {
	time_t lt = time(NULL);
	char buf[30];
	strftime(buf, sizeof(buf), "%a %b %d %T %Z %Y", localtime(&lt));
	fprintf(summarize_fd, "%s\n", buf);
    }

    summarize(summarize_to_file);

    fclose(summarize_fd);
}
Esempio n. 29
0
int main(int argv, char** argc) {
  if (argv > 1) iterations = atoi(argc[1]);
  fill(dpb, dpe, double(init_value));
  fill(Dpb, Dpe, Double(init_value));
  test0(dpb, dpe);
  test(dpb, dpe, d);
  test(Dpb, Dpe, D);
  test(dPb, dPe, d);
  test(DPb, DPe, D);
  test(rdpb, rdpe, d);
  test(rDpb, rDpe, D);
  test(rdPb, rdPe, d);
  test(rDPb, rDPe, D);
  test(rrdpb, rrdpe, d);
  test(rrDpb, rrDpe, D);
  test(rrdPb, rrdPe, d);
  test(rrDPb, rrDPe, D);
  summarize();
  return 0;
}
Esempio n. 30
0
static void history_file_update(struct stats_file *data_file,
				const char *history_file_name)
{
	struct stats_file _history_file;
	struct stats_file tempory_file;

	struct stats_file *history_file = NULL;

	if (stats_open(&_history_file, history_file_name) == 0)
		history_file = &_history_file;

	if (stats_open(&tempory_file, NULL) < 0) {
		if (history_file)
			stats_close(history_file);
		return;
	}

	summarize(data_file, history_file, &tempory_file, 13);

	swap_and_close_files(history_file, &tempory_file);
}