示例#1
0
void
test1 (TestProfile *test_profile,
       File        *from_file,
       File        *to_file,
       File        *out_file,
       File        *re_file)
{
  int ret;
  guint i, change, current_size = cmd_size;
  guint end_size = (cmd_changes * cmd_insertion_length) + cmd_size;
  Instruction* inst;
  struct stat sbuf;
  int zlevel_i, slevel_i;

  seed48 (cmd_seed);

  if ((ret = stat (cmd_data_source, & sbuf)))
    {
      perror (cmd_data_source);
      fail ();
    }

  if (! (data_source_handle = fopen (cmd_data_source, "r")))
    {
      perror (cmd_data_source);
      fail ();
    }

  data_source_length = sbuf.st_size;

  /* arbitrary checks */
  if (data_source_length < (1.5 * end_size))
    g_warning ("data source should be longer\n");

  if ((cmd_changes * cmd_deletion_length) > cmd_size)
    {
      g_warning ("no copies are expected\n");
      fail ();
    }

  inst = g_new0 (Instruction, 1);

  inst->offset = random_offset (cmd_size);
  inst->length = cmd_size;

  current_from_size = write_file (from_file, inst);

  for (change = 0; change < cmd_changes; change += 1)
    inst = perform_change (inst, & current_size);

  current_to_size = write_file (to_file, inst);

  for (slevel_i = 0; slevel_i < ARRAY_LENGTH(cmd_slevels); slevel_i += 1)
    {
      int slevel = cmd_slevels[slevel_i];

      if ((test_profile->flags & TEST_IS_XDELTA) == 0 && slevel_i != 0)
	{
	  continue;
	}

      for (zlevel_i = 0; zlevel_i < ARRAY_LENGTH(cmd_zlevels); zlevel_i += 1)
	{
	  int zlevel = cmd_zlevels[zlevel_i];

	  if (test_profile->flags & TEST_IS_GZIP)
	    {
	      if (zlevel != 1 && zlevel != 9)
		continue;
	    }

	  reset_stats ();

	  for (i = 0; i < cmd_warmups + cmd_reps; i += 1)
	    {
	      if (! run_command (test_profile,
				 zlevel,
				 slevel,
				 from_file,
				 to_file,
				 out_file,
				 re_file,
				 (i >= cmd_warmups) /* true => accounting */))
		{
		  fail ();
		}
	    }

	  report (test_profile, zlevel, slevel);
	}

      g_print ("\n");
    }
}
示例#2
0
void PlaybackEngine::run()
{
	start_lock->unlock();

	do
	{
// Wait for current command to finish
		que->output_lock->lock("PlaybackEngine::run");

		wait_render_engine();


// Read the new command
		que->input_lock->lock("PlaybackEngine::run");
		if(done) return;

		command->copy_from(&que->command);
		que->command.reset();
		que->input_lock->unlock();

//printf("PlaybackEngine::run 1 %d\n", command->command);


		switch(command->command)
		{
// Parameter change only
			case COMMAND_NONE:
//				command->command = last_command;
				perform_change();
				break;

			case PAUSE:
				init_cursor();
				pause_lock->lock("PlaybackEngine::run");
				stop_cursor();
				break;

			case STOP:
// No changing
				break;

			case CURRENT_FRAME:
				last_command = command->command;
				perform_change();
				arm_render_engine();
// Dispatch the command
				start_render_engine();
				break;

			default:
				last_command = command->command;
				is_playing_back = 1;
 				if(command->command == SINGLE_FRAME_FWD ||
					command->command == SINGLE_FRAME_REWIND)
				{
 					command->playbackstart = get_tracking_position();
				}

				perform_change();
				arm_render_engine();

// Start tracking after arming so the tracking position doesn't change.
// The tracking for a single frame command occurs during PAUSE
				init_tracking();

// Dispatch the command
				start_render_engine();
				break;
		}


//printf("PlaybackEngine::run 100\n");
	}while(!done);
}