示例#1
0
文件: framer.hpp 项目: PhySim/Windows
	void endframe()
	{
		currentfreq=elapse()/1000.0;
		current_fps=1/currentfreq;
		total_elapse+=elapse();
		reset();
		start();
		count++;
	}
示例#2
0
bool xTime::elapse(DWORD s)
{
	if (elapse()>=s)
	{
		_elapse += s * ONE_MILLION;
		while (elapse()>=s)
			_elapse += s * ONE_MILLION;
		return true;
	}
	return false;
}
 main(){
     int i,j,k,C=0,st,ed,e;
	 struct timeb before, after;
     double t;
	 /* Timing start */
	 ftime(&before);
	 
     while(scanf("%d",&n) && n>0){
         for(i=1;i<=n;i++)
             for(j=1;j<=n;j++)
                 f[i][j]=0;
         scanf("%d %d %d",&st,&ed,&e);
         while(e--){
             scanf("%d %d %d",&i,&j,&k);
             f[i][j]+=k;
             f[j][i]+=k;
         }
         printf("Network %d\nThe bandwidth is %d.\n\n",++C,flow(st,ed));
     }
	 /* Timing ends */
     ftime(&after);

     /* Get the elapse time between before and after */
     t = elapse(&before, &after);

     /* Print the number of seconds between before and after */
     fprintf(stderr,"The elapse time is: %lf seconds\n", t);

 }
示例#4
0
bool xTime::uElapse(QWORD u)
{
	if (uElapse()>=u)
	{
		_elapse += u;
		while (elapse()>=u)
			_elapse += u;
		return true;
	}
	return false;
}
示例#5
0
bool xTime::milliElapse(QWORD m)
{
	if (milliElapse()>=m)
	{
		_elapse += m*1000;
		while (elapse()>=m)
			_elapse += m*1000;
		return true;
	}
	return false;
}
示例#6
0
文件: Worker.C 项目: brog2610/quinoa
void worker::doWork()
{
  SmallWorkMsg *sm;
  MediumWorkMsg *mm;
  LargeWorkMsg *lm;
  int nbr;

  if (sent == numMsgs) return;
  sent++;

  // generate an event
  int actualMsgSize = msgSize;
  if (msgSize == MIX_MS) actualMsgSize = (actualMsgSize + 1) % 3;
  if (actualMsgSize == SMALL) {
    sm = new SmallWorkMsg;
    memset(sm->data, 0, SM_MSG_SZ*sizeof(int));
    sm->fromPE = myHandle;
    // local ring
    POSE_invoke(workSmall(sm), worker, ((myHandle%numObjs)+1)%numObjs + (numObjs*CkMyPe()), 0);
    // global ring
    //POSE_invoke(workSmall(sm), worker, (myHandle+1)%totalObjs, 0);
    //CkPrintf("%d sending small work to %d at %d. Sent=%d\n",myHandle,((myHandle%numObjs)+1)%numObjs + (numObjs*CkMyPe()),ovt,sent);
  }
  else if (actualMsgSize == MEDIUM) {
    mm = new MediumWorkMsg;
    memset(mm->data, 0, MD_MSG_SZ*sizeof(int));
    POSE_invoke(workMedium(mm), worker, (myHandle+1)%totalObjs, 0);
    //CkPrintf("%d sending medium work to %d at %d\n",myHandle,nbr,ovt);
  }
  else if (actualMsgSize == LARGE) {
    lm = new LargeWorkMsg;
    memset(lm->data, 0, LG_MSG_SZ*sizeof(int));
    POSE_invoke(workLarge(lm), worker, (myHandle+1)%totalObjs, 0);
    //CkPrintf("%d sending large work to %d at %d\n",myHandle,nbr,ovt);
  }
  int elapseCheck = sent * (1.0/localDensity);
  if (OVT() < elapseCheck) elapse(elapseCheck-OVT());
  //CkPrintf("%d sent %d messages out of %d!\n", myHandle, sent, numMsgs);
}
示例#7
0
/*
  processPatch:
  Performs all processing necessary on the given patch.
  Expects a fully prepared patch.

  - read in & range compress the data (rciq).
  - fft the data along azimuth.
  - range migrate the data (rmpatch).
  - azimuth compress the data (acpatch).
  the data is returned in the patch's trans array.
*/
void processPatch(patch *p,const getRec *signalGetRec,const rangeRef *r,
          const satellite *s)
{
  int i;

  update_status("Range compressing");
  if (!quietflag) printf("   RANGE COMPRESSING CHANNELS...\n");
  elapse(0);
  rciq(p,signalGetRec,r);
  if (!quietflag) elapse(1);
  if (s->debugFlag & AZ_RAW_T) debugWritePatch(p,"az_raw_t");

  update_status("Starting azimuth compression");
  if (!quietflag) printf("   TRANSFORMING LINES...\n");
  elapse(0);
  cfft1d(p->n_az,NULL,0);
  for (i=0; i<p->n_range; i++) cfft1d(p->n_az,&p->trans[i*p->n_az],-1);
  if (!quietflag) elapse(1);
  if (s->debugFlag & AZ_RAW_F) debugWritePatch(p,"az_raw_f");
  if (!(s->debugFlag & NO_RCM))
    {
      update_status("Range cell migration");
      if (!quietflag) printf("   START RANGE MIGRATION CORRECTION...\n");
      elapse(0);
      rmpatch(p,s);
      if (!quietflag) elapse(1);
      if (s->debugFlag & AZ_MIG_F) debugWritePatch(p,"az_mig_f");
    }
  update_status("Finishing azimuth compression");
  if (!quietflag) printf("   INVERSE TRANSFORMING LINES...\n");
  elapse(0);
  acpatch(p,s);
  if (!quietflag) elapse(1);

  /*    if (!quietflag) printf("  Range-Doppler done...\n");*/
}
示例#8
0
文件: framer.hpp 项目: PhySim/Windows
	float elapsed()
	{
		return (float)elapse();
	}
示例#9
0
文件: framer.hpp 项目: PhySim/Windows
	float remainingfreetime()
	{
		if(elapse()/1000.0<minfreq)
			return double(minfreq)-double(elapse()/1000.0);
		else return 0;
	}
示例#10
0
double RecvFile::transferRateAvg() const
{
    return m_bytesReaded / (double)elapse();
}
示例#11
0
/*
  writePatch:
  Outputs one full patch of data to the given file.
*/
void writePatch(const patch *p,const satellite *s,meta_parameters *meta,
    const file *f,int patchNo)
{
  int outLine;       /* Counter for line base output */
  FILE *fp_amp,*fp_cpx;  /* File pointers for the amplitude and  complex outputs*/
  FILE *fp_pwr,*fp_sig;  /* File pointers for the power and Sigma_0 outputs */
  FILE *fp_gam,*fp_bet;  /* File pointers for the Gamma_0 and Beta_0 outputs */
  complexFloat *outputBuf; /* Buffer for one line of patch = n_range    */
  complexFloat *mlBuf;   /* Buffer for multilooking the amplitude image */
  float *amps;           /* Output Amplitude  = n_az/nlooks X n_range */
  float *pwrs;       /* Output power */
  char *openMode="ab";   /* Normally append output.*/
  int mlCount=0;     /* Counter for setting up the multilook buffer */
  int writeNoiseTable=0; /* Flag to determine whether to write the noise table and
                antenna pattern */
  int off_slc = f->n_az_valid * (patchNo-1);
  int off_ml = f->n_az_valid * (patchNo-1) / (f->nlooks);

  if (patchNo==1)
    openMode="wb";   /* for first patch, truncate output. */

  if ((patchNo==1) && (s->vecLen!=0))
    writeNoiseTable=1;  /* If first patch AND antenna pattern correction,
               write the noise table */

  update_status("Range-doppler done");
  if (!quietflag) printf("   WRITING PATCH OUT...\n");
  elapse(0);

  /* Allocate buffer space  ------------------------*/
  amps = (float *) MALLOC(p->n_range*sizeof(float));
  pwrs = (float *) MALLOC(p->n_range*sizeof(float));

  outputBuf = (complexFloat *)MALLOC(p->n_range*sizeof(complexFloat));
  mlBuf = (complexFloat *)MALLOC(p->n_range*f->nlooks*sizeof(complexFloat));

  /* Fill in metadata */
  meta_get_latLon(meta, meta->general->line_count/2,
          meta->general->sample_count/2, 0.0,
          &(meta->general->center_latitude),
          &(meta->general->center_longitude));

  meta_parameters *metaCpx=meta_copy(meta);
  metaCpx->general->data_type = COMPLEX_REAL32;
  metaCpx->general->image_data_type = COMPLEX_IMAGE;
  metaCpx->general->radiometry = r_AMP;
  metaCpx->general->line_count = f->n_az_valid * patchNo;
  metaCpx->general->sample_count = p->n_range;
  meta_get_latLon(metaCpx, metaCpx->general->line_count/2,
          metaCpx->general->sample_count/2, 0.0,
          &(metaCpx->general->center_latitude),
          &(metaCpx->general->center_longitude));
  metaCpx->general->start_line = f->firstLineToProcess + s->dop_precomp + 1;
  metaCpx->general->start_sample = f->skipFile + 1;
  metaCpx->general->x_pixel_size = f->rngpix;
  metaCpx->general->y_pixel_size = f->azpix;
  meta_write(metaCpx, f->out_cpx);
  fp_cpx=fopenImage(f->out_cpx,openMode);

  meta_parameters *metaAmp=meta_copy(metaCpx);
  metaAmp->general->data_type = REAL32;
  metaAmp->general->image_data_type = AMPLITUDE_IMAGE;
  metaAmp->general->radiometry = r_AMP;
  metaAmp->general->line_count = f->n_az_valid / f->nlooks * patchNo;
  metaAmp->general->y_pixel_size *= f->nlooks;
  metaAmp->sar->azimuth_time_per_pixel *= f->nlooks;
  meta_write(metaAmp, f->out_amp);
  fp_amp=fopenImage(f->out_amp,openMode);

  meta_parameters *metaPower=0, *metaSigma=0, *metaGamma=0, *metaBeta=0;
  if (s->imageType.power) {
    metaPower=meta_copy(metaAmp);
    metaPower->general->image_data_type = AMPLITUDE_IMAGE;
    metaPower->general->radiometry = r_POWER;
    meta_write(metaPower, f->out_pwr);
    fp_pwr=fopenImage(f->out_pwr,openMode);
  }
  if (s->imageType.sigma) {
    metaSigma=meta_copy(metaAmp);
    metaSigma->general->image_data_type = AMPLITUDE_IMAGE;
    metaSigma->general->radiometry = r_SIGMA;
    meta_write(metaSigma, f->out_sig);
    fp_sig=fopenImage(f->out_sig,openMode);
  }
  if (s->imageType.gamma) {
    metaGamma=meta_copy(metaAmp);
    metaGamma->general->image_data_type = AMPLITUDE_IMAGE;
    metaGamma->general->image_data_type = r_GAMMA;
    meta_write(metaGamma, f->out_gam);
    fp_gam=fopenImage(f->out_gam,openMode);
  }
  if (s->imageType.beta) {
    metaBeta=meta_copy(metaAmp);
    metaBeta->general->image_data_type = AMPLITUDE_IMAGE;
    metaBeta->general->radiometry = r_BETA;
    meta_write(metaBeta, f->out_bet);
    fp_bet=fopenImage(f->out_bet,openMode);
  }

  /* This gets messy */
  for (outLine = 0; outLine < f->n_az_valid; outLine++)
  {
      int j; /* loop counter */
      int base = f->firstOutputLine+outLine; /* loop counter for transposed data */

      if(writeNoiseTable==1) {
          if (!quietflag) printf("   Writing .noise and .ant files\n");
      }

      /* Print statement for the antenna pattern correction option */
      if(s->vecLen==0) {
          if(!quietflag && (outLine % 1024 == 0)) {
              printf("   ...Writing Line %i\n",outLine);
          }
      }
      if(s->vecLen!=0) {
          if(!quietflag && (outLine % 1024 == 0)) {
              printf("   ...Writing Line %i and applying Antenna Pattern Correction\n",
                     outLine);
          }
      }

      /* Fill up the buffers */
      for (j=0; j<p->n_range; j++,base+=p->n_az)
      {
          outputBuf[j] = p->trans[base];

          /* For speed, if we aren't correcting the antenna pattern,
             write the multi-look buffer now */
          if(s->vecLen==0)
          {
              mlBuf[j+mlCount*p->n_range].real = outputBuf[j].real;
              mlBuf[j+mlCount*p->n_range].imag = outputBuf[j].imag;
          }
      }

      /* Apply the Antenna Pattern Correction if desired */
      if(s->vecLen!=0)
      {

          /* On the first time through, write out the noise table */
          if(writeNoiseTable==1)
          {
              writeTable(meta,s,p->n_range);
              writeNoiseTable=0;
          }

          antptn_correct(meta,outputBuf,base,p->n_range,s);
          if(!quietflag && (j==0)) printf("   Correcting Line %d\n",outLine);

          /* Otherwise, write the multi-look buffer now */
          for(j=0;j<p->n_range;j++)
          {
              mlBuf[j+mlCount*p->n_range].real = outputBuf[j].real;
              mlBuf[j+mlCount*p->n_range].imag = outputBuf[j].imag;
          }
      }

      put_complexFloat_line(fp_cpx, metaCpx, outLine+off_slc, outputBuf);
      mlCount+=1;
      /* Multilook takes f->nlooks lines of data and averages them together,
         and writes one line on return */
      if(mlCount==f->nlooks)
      {
          /* multilook on the power image, then use the power image to generate
             an amplitude, and all other detected images from the command line.
             Be careful because I recycle amps after writing out the line of
             amplitude data, and it gets used as the sigma_0, beta_0, and gamma_0
             line. It my be confusing, but it uses less memory.*/
          multilook(mlBuf,p->n_range,f->nlooks,pwrs);
          intensity(p->n_range,pwrs,amps);

          put_float_line(fp_amp, metaAmp, outLine/f->nlooks+off_ml, amps);

          if (s->imageType.power) {
              put_float_line(fp_pwr, metaPower, outLine/f->nlooks+off_ml, pwrs);
          }
          if (s->imageType.sigma)
          {
              calculateRCS(SIGMA_0, meta, pwrs, amps,
                           base-mlCount/2, p->n_range,s);
              put_float_line(fp_sig, metaSigma, outLine/f->nlooks+off_ml, amps);
          }
          if (s->imageType.gamma)
          {
              calculateRCS(GAMMA_0, meta, pwrs, amps,
                           base-mlCount/2, p->n_range,s);
              put_float_line(fp_gam, metaGamma, outLine/f->nlooks+off_ml, amps);
          }
          if (s->imageType.beta)
          {
              calculateRCS(BETA_0, meta, pwrs, amps,
                           base-mlCount/2, p->n_range,s);
              put_float_line(fp_bet, metaBeta, outLine/f->nlooks+off_ml, amps);
          }

          mlCount=0;
      }
  }
  FCLOSE(fp_cpx);
  FCLOSE(fp_amp);
  if (s->imageType.power)
    FCLOSE(fp_pwr);
  if (s->imageType.sigma)
    FCLOSE(fp_sig);
  if (s->imageType.gamma)
    FCLOSE(fp_gam);
  if (s->imageType.beta)
    FCLOSE(fp_bet);

  if (!quietflag) printf("\n");
  if (logflag) printLog("\n");
  if (!quietflag) {
    printf("   AMPLITUDE IMAGE FINISHED: Wrote %i lines and %i samples\n",
           f->n_az_valid/f->nlooks,p->n_range);
    printf("   PATCH FINISHED: Wrote %i lines of %i samples (float)\n\n",
           f->n_az_valid,p->n_range);
  }
  FREE((void *)amps);
  FREE((void *)pwrs);
  FREE((void *)outputBuf);
  FREE((void *)mlBuf);
  meta_free(metaAmp);
  meta_free(metaCpx);
  if (metaPower) meta_free(metaPower);
  if (metaSigma) meta_free(metaSigma);
  if (metaGamma) meta_free(metaGamma);
  if (metaBeta)  meta_free(metaBeta);
  if (!quietflag) elapse(1);
}
示例#12
0
文件: speed.c 项目: Cai900205/test
static int avg(u64 *a)
{
	int e = elapse(a);
	int d = test_start;
	return (e + (d / 2)) / d;
}