Exemple #1
0
float Ramp::progress() const {
	// Compute progress as % of duration.
	float prog = elapsed() / _duration;
	prog = constrain(prog, 0, 1);
	return prog;
}
Exemple #2
0
 void pause(void)
 {
     pause_elap_ = elapsed();
 }
Exemple #3
0
float SVGAnimationElement::getCurrentTime() const
{
    return narrowPrecisionToFloat(elapsed().value());
}
Exemple #4
0
void QgsBench::render()
{
  QgsDebugMsg( "entered" );

  QgsDebugMsg( "extent: " +  mMapRenderer->extent().toString() );

  QMap<QString, QgsMapLayer*> layersMap = QgsMapLayerRegistry::instance()->mapLayers();

  QStringList layers( layersMap.keys() );

  mMapRenderer->setLayerSet( layers );

  if ( mSetExtent )
  {
    mMapRenderer->setExtent( mExtent );
  }

  // Maybe in future
  //outputCRS = QgsCRSCache::instance()->crsByAuthId( crsId );
  //mMapRenderer->setMapUnits( outputCRS.mapUnits() );
  //mMapRenderer->setDestinationCrs( outputCRS );

  // TODO: this should be probably set according to project
  mMapRenderer->setProjectionsEnabled( true );

  // Necessary?
  //mMapRenderer->setLabelingEngine( new QgsPalLabeling() );

  mImage = new QImage( mWidth, mHeight, QImage::Format_ARGB32_Premultiplied );
  mImage->fill( 0 );

  mMapRenderer->setOutputSize( QSize( mWidth, mHeight ), mImage->logicalDpiX() );

  QPainter painter( mImage );

  painter.setRenderHints( mRendererHints );

  for ( int i = 0; i < mIterations; i++ )
  {
    start();
    mMapRenderer->render( &painter );
    elapsed();
  }

  mLogMap.insert( "iterations", mTimes.size() );
  mLogMap.insert( "revision", QGSVERSION );

  // Calc stats: user, sys, total
  double min[4], max[4];
  double stdev[4] = {0.};
  double maxdev[4] = {0.};
  double avg[4] = {0.};

  for ( int t = 0; t < 4; t++ )
  {
    for ( int i = 0; i < mTimes.size(); i++ )
    {
      avg[t] += mTimes[i][t];

      if ( i == 0 || mTimes[i][t] < min[t] ) min[t] = mTimes[i][t];
      if ( i == 0 || mTimes[i][t] > max[t] ) max[t] = mTimes[i][t];
    }
    avg[t] /= mTimes.size();
  }

  QMap<QString, QVariant> timesMap;
  for ( int t = 0; t < 4; t++ )
  {
    if ( mIterations > 1 )
    {
      for ( int i = 0; i < mTimes.size(); i++ )
      {
        double d = fabs( avg[t] - mTimes[i][t] );
        stdev[t] += pow( d, 2 );
        if ( i == 0 || d > maxdev[t] ) maxdev[t] = d;
      }

      stdev[t] = sqrt( stdev[t] / mTimes.size() );
    }

    const char *pre[] = { "user", "sys", "total", "wall" };

    QMap<QString, QVariant> map;

    map.insert( "min", min[t] );
    map.insert( "max", max[t] );
    map.insert( "avg", avg[t] );
    map.insert( "stdev", stdev[t] );
    map.insert( "maxdev", maxdev[t] );

    timesMap.insert( pre[t], map );
  }
  mLogMap.insert( "times", timesMap );
}
Exemple #5
0
 float rate() const {
     if (elapsed() == 0.0f) {
         return 0.0f;
     }
     return (float) count() / elapsed();
 }
Exemple #6
0
int
timelog (const char* message)
{
  struct timespec ts = elapsed ();
  return (printf ("[%06d.%09d] %s\n", ts.tv_sec, ts.tv_nsec, message));
}
Exemple #7
0
void main(int argc,char* argv[]){

  struct timeval tv0,tv1;

  gettimeofday(&tv0,NULL);

  int res = 0;
  int launched_num = 0;
  int received_num = 0;

  register_signal();

  srand(100);

  while(launched_num < num){

    pid_t child;
    int random;

    random = rand()%6;
    
    child = fork();
    
    if(child == 0){

      printf("Rand = %d\n",random);

      switch(random){
      case 0:
	execl(P1,NULL);
	break;
      case 1:
	execl(P2,NULL);
	break;
      case 2:
	execl(P3,NULL);
	break;
      case 3:
	execl(P4,NULL);
	break;
      case 4:
	execl(P5,NULL);
	break;
      case 5:
	execl(P6,NULL);
	break;
      }

      res ++;
      
      exit(0);
    }else{

      PIDs[launched_num] = child;
      Procs[launched_num] = random;
      launched_num++;
    }

    sleep(1);

  }

  while(received_num < num){

    pid_t res;
    int status;

    res = wait(&status);

    received_num++;
  }

  printf("FINISH!!!!!!!\n");

  gettimeofday(&tv1,NULL);
  
  printf("Result time : %f[sec]\n",elapsed(tv0,tv1));
}
static void run(int object_size)
{
	struct drm_i915_gem_execbuffer2 execbuf;
	struct drm_i915_gem_exec_object2 exec[3];
	struct drm_i915_gem_relocation_entry reloc[4];
	uint32_t buf[20];
	uint32_t handle, src, dst;
	int fd, len, count;
	int ring;

	fd = drm_open_any();
	handle = gem_create(fd, 4096);
	src = gem_create(fd, object_size);
	dst = gem_create(fd, object_size);

	len = gem_linear_blt(buf, src, dst, object_size, reloc);
	gem_write(fd, handle, 0, buf, len);

	exec[0].handle = src;
	exec[0].relocation_count = 0;
	exec[0].relocs_ptr = 0;
	exec[0].alignment = 0;
	exec[0].offset = 0;
	exec[0].flags = 0;
	exec[0].rsvd1 = 0;
	exec[0].rsvd2 = 0;

	exec[1].handle = dst;
	exec[1].relocation_count = 0;
	exec[1].relocs_ptr = 0;
	exec[1].alignment = 0;
	exec[1].offset = 0;
	exec[1].flags = 0;
	exec[1].rsvd1 = 0;
	exec[1].rsvd2 = 0;

	exec[2].handle = handle;
	exec[2].relocation_count = len > 40 ? 4 : 2;
	exec[2].relocs_ptr = (uintptr_t)reloc;
	exec[2].alignment = 0;
	exec[2].offset = 0;
	exec[2].flags = 0;
	exec[2].rsvd1 = 0;
	exec[2].rsvd2 = 0;

	ring = 0;
	if (HAS_BLT_RING(intel_get_drm_devid(fd)))
		ring = I915_EXEC_BLT;

	execbuf.buffers_ptr = (uintptr_t)exec;
	execbuf.buffer_count = 3;
	execbuf.batch_start_offset = 0;
	execbuf.batch_len = len;
	execbuf.cliprects_ptr = 0;
	execbuf.num_cliprects = 0;
	execbuf.DR1 = 0;
	execbuf.DR4 = 0;
	execbuf.flags = ring;
	i915_execbuffer2_set_context_id(execbuf, 0);
	execbuf.rsvd2 = 0;

	for (count = 1; count <= 1<<17; count <<= 1) {
		struct timeval start, end;

		gettimeofday(&start, NULL);
		if (gem_exec(fd, &execbuf, count))
			exit(1);
		gem_sync(fd, handle);
		gettimeofday(&end, NULL);
		printf("Time to blt %d bytes x %6d:	%7.3fµs, %s\n",
		       object_size, count,
		       elapsed(&start, &end, count),
		       bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
		fflush(stdout);
	}
	gem_close(fd, handle);

	close(fd);
}
Exemple #9
0
void Timer::updateFPS() {
  timespec now;
  clock_gettime(CLOCK_MONOTONIC, &now);
  frameTime = elapsed(lastTime, now);
  lastTime = now;
}
Exemple #10
0
inline double FpsCounter::fps() {
    return (double) frames() / elapsed();
}
Exemple #11
0
void SMILTimeContainer::timerFired(Timer<SMILTimeContainer>*)
{
    ASSERT(m_beginTime);
    ASSERT(!m_pauseTime);
    updateAnimations(elapsed());
}
Exemple #12
0
int32_t
main(int32_t argc, char *argv[])
{
	struct bthid_server	 srv;
	struct sigaction	 sa;
	char const		*pid_file = BTHIDD_PIDFILE;
	char			*ep;
	int32_t			 opt, detach, tval;

	memset(&srv, 0, sizeof(srv));
	memset(&srv.bdaddr, 0, sizeof(srv.bdaddr));
	detach = 1;
	tval = 10; /* sec */

	while ((opt = getopt(argc, argv, "a:c:dH:hp:t:")) != -1) {
		switch (opt) {
		case 'a': /* BDADDR */
			if (!bt_aton(optarg, &srv.bdaddr)) {
				struct hostent  *he;

				if ((he = bt_gethostbyname(optarg)) == NULL)
					errx(1, "%s: %s", optarg, hstrerror(h_errno));

				memcpy(&srv.bdaddr, he->h_addr, sizeof(srv.bdaddr));
			}
			break;
			
		case 'c': /* config file */
			config_file = optarg;
			break;

		case 'd': /* do not detach */
			detach = 0;
			break;

		case 'H': /* hids file */
			hids_file = optarg;
			break;

		case 'p': /* pid file */
			pid_file = optarg;
			break;

		case 't': /* rescan interval */
			tval = strtol(optarg, (char **) &ep, 10);
			if (*ep != '\0' || tval <= 0)
				usage();
			break;

		case 'h':
		default:
			usage();
			/* NOT REACHED */
		}
	}

	openlog(BTHIDD_IDENT, LOG_PID|LOG_PERROR|LOG_NDELAY, LOG_USER);

	/* Become daemon if required */
	if (detach && daemon(0, 0) < 0) {
		syslog(LOG_CRIT, "Could not become daemon. %s (%d)",
			strerror(errno), errno);
		exit(1);
	}

	/* Install signal handler */
	memset(&sa, 0, sizeof(sa));
	sa.sa_handler = sighandler;

	if (sigaction(SIGTERM, &sa, NULL) < 0 ||
	    sigaction(SIGHUP, &sa, NULL) < 0 ||
	    sigaction(SIGINT, &sa, NULL) < 0) {
		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
			strerror(errno), errno);
		exit(1);
	}

	sa.sa_handler = SIG_IGN;
	if (sigaction(SIGPIPE, &sa, NULL) < 0) {
		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
			strerror(errno), errno);
		exit(1);
	}

	sa.sa_handler = SIG_IGN;
	sa.sa_flags = SA_NOCLDSTOP|SA_NOCLDWAIT;
	if (sigaction(SIGCHLD, &sa, NULL) < 0) {
		syslog(LOG_CRIT, "Could not install signal handlers. %s (%d)",
			strerror(errno), errno);
		exit(1);
	}

	if (read_config_file() < 0 || read_hids_file() < 0 ||
	    server_init(&srv) < 0 || write_pid_file(pid_file) < 0)
		exit(1);

	for (done = 0; !done; ) {
		if (elapsed(tval))
			client_rescan(&srv);

		if (server_do(&srv) < 0)
			break;
	}

	server_shutdown(&srv);
	remove_pid_file(pid_file);
	clean_config();
	closelog();

	return (0);
}
Exemple #13
0
int64_t Timer::restart()
{
    int64_t milli = elapsed();
    start();
    return milli;
}
Exemple #14
0
  void
DoThru(
    tcb *ptcb,
    int nbytes)
{
  double etime;
  double thruput;
  char *myname, *hisname;

  /* init, if not already done */
  if (ZERO_TIME(&ptcb->thru_firsttime)) {
    char title[210];

    ptcb->thru_firsttime = current_time;
    ptcb->thru_lasttime = current_time;
    ptcb->thru_pkts = 1;
    ptcb->thru_bytes = nbytes;


    /* bug fix from Michele Clark - UNC */
    if (&ptcb->ptp->a2b == ptcb) {
      myname = ptcb->ptp->a_endpoint;
      hisname = ptcb->ptp->b_endpoint;
    } else {
      myname = ptcb->ptp->b_endpoint;
      hisname = ptcb->ptp->a_endpoint;
    }
    /* create the plotter file */
    snprintf(title,sizeof(title),"%s_==>_%s (throughput)",
        myname, hisname);
    ptcb->thru_plotter = new_plotter(ptcb,NULL,title,
        "time","thruput (bytes/sec)",
        THROUGHPUT_FILE_EXTENSION);
    if (graph_time_zero) {
      /* set graph zero points */
      plotter_nothing(ptcb->thru_plotter, current_time);
    }

    /* create lines for average and instantaneous values */
    ptcb->thru_avg_line =
      new_line(ptcb->thru_plotter, "avg. tput", "blue");
    ptcb->thru_inst_line =
      new_line(ptcb->thru_plotter, "inst. tput", "red");

    return;
  }

  /* if no data, then nothing to do */
  if (nbytes == 0)
    return;

  /* see if we should output the stats yet */
  if (ptcb->thru_pkts+1 >= thru_interval) {

    /* compute stats for this interval */
    etime = elapsed(ptcb->thru_firsttime,current_time);
    if (etime == 0.0)
      etime = 1000;	/* ick, what if "no time" has passed?? */
    thruput = (double) ptcb->thru_bytes / ((double) etime / 1000000.0);

    /* instantaneous plot */
    extend_line(ptcb->thru_inst_line,
        current_time, (int) thruput);

    /* compute stats for connection lifetime */
    etime = elapsed(ptcb->ptp->first_time,current_time);
    if (etime == 0.0)
      etime = 1000;	/* ick, what if "no time" has passed?? */
    thruput = (double) ptcb->data_bytes / ((double) etime / 1000000.0);

    /* long-term average */
    extend_line(ptcb->thru_avg_line,
        current_time, (int) thruput);

    /* reset stats for this interval */
    ptcb->thru_firsttime = current_time;
    ptcb->thru_pkts = 0;
    ptcb->thru_bytes = 0;
  }

  /* immediate value in yellow ticks */
  if (plot_tput_instant) {
    etime = elapsed(ptcb->thru_lasttime,current_time);
    if (etime == 0.0)
      etime = 1000;	/* ick, what if "no time" has passed?? */
    thruput = (double) nbytes / ((double) etime / 1000000.0);
    plotter_temp_color(ptcb->thru_plotter,"yellow");
    plotter_dot(ptcb->thru_plotter,
        current_time, (int) thruput);
  }

  /* add in the latest packet */
  ptcb->thru_lasttime = current_time;
  ++ptcb->thru_pkts;
  ptcb->thru_bytes += nbytes;
}
Exemple #15
0
 void measureElapsed(boost::timer::cpu_timer const& timer) {
   boost::timer::cpu_times elapsed(timer.elapsed());
   const double ns = 1e-9;
   sec = elapsed.user * ns;
   wallSec = elapsed.wall * ns;
 }
Exemple #16
0
int main(int argc, char **argv)
{
	int fd = drm_open_driver(DRIVER_INTEL);
	int domain = I915_GEM_DOMAIN_GTT;
	enum dir { READ, WRITE } dir = READ;
	void *buf = malloc(OBJECT_SIZE);
	uint32_t handle;
	int reps = 13;
	int c, size;

	while ((c = getopt (argc, argv, "D:d:r:")) != -1) {
		switch (c) {
		case 'd':
			if (strcmp(optarg, "cpu") == 0)
				domain = I915_GEM_DOMAIN_CPU;
			else if (strcmp(optarg, "gtt") == 0)
				domain = I915_GEM_DOMAIN_GTT;
			break;
		case 'D':
			if (strcmp(optarg, "read") == 0)
				dir = READ;
			else if (strcmp(optarg, "write") == 0)
				dir = WRITE;
			else
				abort();
			break;

		case 'r':
			reps = atoi(optarg);
			if (reps < 1)
				reps = 1;
			break;

		default:
			break;
		}
	}

	handle = gem_create(fd, OBJECT_SIZE);
	for (size = 1; size <= OBJECT_SIZE; size <<= 1) {
		igt_stats_t stats;
		int n;

		igt_stats_init_with_size(&stats, reps);

		for (n = 0; n < reps; n++) {
			struct timespec start, end;

			gem_set_domain(fd, handle, domain, domain);

			clock_gettime(CLOCK_MONOTONIC, &start);
			if (dir == READ)
				gem_read(fd, handle, 0, buf, size);
			else
				gem_write(fd, handle, 0, buf, size);
			clock_gettime(CLOCK_MONOTONIC, &end);

			igt_stats_push(&stats, elapsed(&start, &end));
		}

		printf("%7.3f\n", igt_stats_get_trimean(&stats)/1000);
		igt_stats_fini(&stats);
	}

	return 0;
}
 ~_lc_auto_save_runtime() { runtime = elapsed(); }
Exemple #18
0
 // end clock on dtor
 ~Timer()
 {
   std::cout << "TIME: " << elapsed() << '\n';
 }
Exemple #19
0
void
display(void)
{
    static char s[256], t[32];
    static char* p;
    static int frames = 0;

    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glPushMatrix();

    glTranslatef(pan_x, pan_y, 0.0);

    gltbMatrix();

#if 0   /* glmDraw() performance test */
    if (material_mode == 0) { 
	if (facet_normal)
	    glmDraw(model, GLM_FLAT);
	else
	    glmDraw(model, GLM_SMOOTH);
    } else if (material_mode == 1) {
	if (facet_normal)
	    glmDraw(model, GLM_FLAT | GLM_COLOR);
	else
	    glmDraw(model, GLM_SMOOTH | GLM_COLOR);
    } else if (material_mode == 2) {
	if (facet_normal)
	    glmDraw(model, GLM_FLAT | GLM_MATERIAL);
	else
	    glmDraw(model, GLM_SMOOTH | GLM_MATERIAL);
    }
#else
    glCallList(model_list);
#endif

    glDisable(GL_LIGHTING);
    if (bounding_box) {
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);
	glEnable(GL_CULL_FACE);
	glColor4f(1.0, 0.0, 0.0, 0.25);
	glutSolidCube(2.0);
	glDisable(GL_BLEND);
    }

    glPopMatrix();

    if (stats) {
	/* XXX - this could be done a _whole lot_ faster... */
	int height = glutGet(GLUT_WINDOW_HEIGHT);
	glColor3ub(0, 0, 0);
	sprintf(s, "%s\n%d vertices\n%d triangles\n%d normals\n"
		"%d texcoords\n%d groups\n%d materials",
	        model->pathname, model->numvertices, model->numtriangles, 
		model->numnormals, model->numtexcoords, model->numgroups,
		model->nummaterials);
	shadowtext(5, height-(5+18*1), s);
    }

    /* spit out frame rate. */
    frames++;
    if (frames > NUM_FRAMES) {
	sprintf(t, "%g fps", frames/elapsed());
	frames = 0;
    }
    if (performance) {
	shadowtext(5, 5, t);
    }

    glutSwapBuffers();
    glEnable(GL_LIGHTING);
}
static void thread_performance(unsigned mask)
{
	const int loops = 4096;
	int n, count;
	int fd, num_fences;
	double linear[2], tiled[2];

	fd = drm_open_any();

	num_fences = gem_available_fences(fd);
	igt_require(num_fences > 0);

	for (count = 2; count < 4*num_fences; count *= 2) {
		const int nthreads = (mask & READ ? count : 0) + (mask & WRITE ? count : 0);
		struct timeval start, end;
		struct thread_performance readers[count];
		struct thread_performance writers[count];
		uint32_t handle[count];
		void *ptr[count];

		for (n = 0; n < count; n++) {
			handle[n] = gem_create(fd, OBJECT_SIZE);
			ptr[n] = gem_mmap(fd, handle[n], OBJECT_SIZE, PROT_READ | PROT_WRITE);
			igt_assert(ptr[n]);

			if (mask & READ) {
				readers[n].id = n;
				readers[n].direction = READ;
				readers[n].ptr = ptr;
				readers[n].count = count;
				readers[n].loops = loops;
			}

			if (mask & WRITE) {
				writers[n].id = count - n - 1;
				writers[n].direction = WRITE;
				writers[n].ptr = ptr;
				writers[n].count = count;
				writers[n].loops = loops;
			}
		}

		gettimeofday(&start, NULL);
		for (n = 0; n < count; n++) {
			if (mask & READ)
				pthread_create(&readers[n].thread, NULL, read_thread_performance, &readers[n]);
			if (mask & WRITE)
				pthread_create(&writers[n].thread, NULL, write_thread_performance, &writers[n]);
		}
		for (n = 0; n < count; n++) {
			if (mask & READ)
				pthread_join(readers[n].thread, NULL);
			if (mask & WRITE)
				pthread_join(writers[n].thread, NULL);
		}
		gettimeofday(&end, NULL);

		linear[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
		igt_info("%s rate for %d linear surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, linear[count != 2]);

		for (n = 0; n < count; n++)
			gem_set_tiling(fd, handle[n], I915_TILING_X, 1024);

		gettimeofday(&start, NULL);
		for (n = 0; n < count; n++) {
			if (mask & READ)
				pthread_create(&readers[n].thread, NULL, read_thread_performance, &readers[n]);
			if (mask & WRITE)
				pthread_create(&writers[n].thread, NULL, write_thread_performance, &writers[n]);
		}
		for (n = 0; n < count; n++) {
			if (mask & READ)
				pthread_join(readers[n].thread, NULL);
			if (mask & WRITE)
				pthread_join(writers[n].thread, NULL);
		}
		gettimeofday(&end, NULL);

		tiled[count != 2] = nthreads * loops / elapsed(&start, &end) / (OBJECT_SIZE / 4096);
		igt_info("%s rate for %d tiled surfaces, %d threads:	%7.3fMiB/s\n", direction_string(mask), count, nthreads, tiled[count != 2]);

		for (n = 0; n < count; n++) {
			munmap(ptr[n], OBJECT_SIZE);
			gem_close(fd, handle[n]);
		}
	}

	errno = 0;
	igt_assert(linear[1] > 0.75 * linear[0]);
	igt_assert(tiled[1] > 0.75 * tiled[0]);
}
Exemple #21
0
qint64 QBenchmarkTickMeasurer::checkpoint()
{
    CycleCounterTicks now = getticks();
    return qRound64(elapsed(now, startTicks));
}
Exemple #22
0
Fichier : time.c Projet : NFFT/nfft
R Y(elapsed_seconds)(ticks t1, ticks t0)
{
  UNUSED(t1);
  UNUSED(t0);
  return (R)(elapsed(t1,t0)) / (R)(TICKS_PER_SECOND);
}
Exemple #23
0
void
udptrace_done(void)
{
    udp_pair *pup;
    int ix;
    double etime;

    if(do_udp) { // Just a quick sanity check to make sure if we need to do 
	         // anything at all..
	 if(!run_continuously) {
	      if (!printsuppress) {
		   if (udp_trace_count == 0) {
			fprintf(stdout,"no traced UDP packets\n");
			return;
		   } else {
			if ((tcp_trace_count > 0) && (!printbrief))
			     printf("\n============================================================\n");
			fprintf(stdout,"UDP connection info:\n");
		   }
	      }
	      
	      if (!printbrief)
		   fprintf(stdout,"%d UDP %s traced:\n",
			   num_udp_pairs + 1,
			   num_udp_pairs==0?"connection":"connections");
	 }
	 
	 /* elapsed time */
	 etime = elapsed(first_packet,last_packet);
	 
	 if (ctrunc > 0) {
	      fprintf(stdout,
		      "*** %lu packets were too short to process at some point\n",
		      ctrunc);
	      if (!warn_printtrunc)
		   fprintf(stdout,"\t(use -w option to show details)\n");
	 }
	 if (debug>1)
	      fprintf(stdout,"average search length: %d\n",
		      search_count / packet_count);
	 
	 /* print each connection */
	 if(!run_continuously) {
	      if (!printsuppress) {
		   for (ix = 0; ix <= num_udp_pairs; ++ix) {
			pup = utp[ix];
			if (!pup->ignore_pair) {
			     if (printbrief) {
				  fprintf(stdout,"%3d: ", ix+1);
				  UDPPrintBrief(pup);
			     } else {
				  if (ix > 0)
				       fprintf(stdout,
					       "================================\n");
				  fprintf(stdout,"UDP connection %d:\n", ix+1);
				  UDPPrintTrace(pup);
			     }
			}
		   }
	      }
	 }
    }
}
Exemple #24
0
 /** log usage now, without preventing logging at destructor */
 void report() {
   if (stringConsumer) stringConsumer("(FINISHED) " + elapsed().str());
 }
Exemple #25
0
 double value(void)
 {
     return ModelT::second(elapsed());
 }
Exemple #26
0
 std::string str() const { return elapsed().str(); }
Exemple #27
0
int main(int argc, char **argv)
{
	int fd = drm_open_driver(DRIVER_INTEL);
	enum map {CPU, GTT, WC} map = CPU;
	enum dir {READ, WRITE, CLEAR, FAULT} dir = READ;
	int tiling = I915_TILING_NONE;
	struct timespec start, end;
	void *buf = malloc(OBJECT_SIZE);
	uint32_t handle;
	void *ptr, *src, *dst;
	int reps = 1;
	int loops;
	int c;

	while ((c = getopt (argc, argv, "m:d:r:t:")) != -1) {
		switch (c) {
		case 'm':
			if (strcmp(optarg, "cpu") == 0)
				map = CPU;
			else if (strcmp(optarg, "gtt") == 0)
				map = GTT;
			else if (strcmp(optarg, "wc") == 0)
				map = WC;
			else
				abort();
			break;

		case 'd':
			if (strcmp(optarg, "read") == 0)
				dir = READ;
			else if (strcmp(optarg, "write") == 0)
				dir = WRITE;
			else if (strcmp(optarg, "clear") == 0)
				dir = CLEAR;
			else if (strcmp(optarg, "fault") == 0)
				dir = FAULT;
			else
				abort();
			break;

		case 't':
			if (strcmp(optarg, "x") == 0)
				tiling = I915_TILING_X;
			else if (strcmp(optarg, "y") == 0)
				tiling = I915_TILING_Y;
			else if (strcmp(optarg, "none") == 0)
				tiling = I915_TILING_NONE;
			else
				abort();
			break;

		case 'r':
			reps = atoi(optarg);
			if (reps < 1)
				reps = 1;
			break;

		default:
			break;
		}
	}

	handle = gem_create(fd, OBJECT_SIZE);
	switch (map) {
	case CPU:
		ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
		gem_set_domain(fd, handle, I915_GEM_DOMAIN_CPU, I915_GEM_DOMAIN_CPU);
		break;
	case GTT:
		ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_WRITE);
		gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
		break;
	case WC:
		ptr = gem_mmap__wc(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
		gem_set_domain(fd, handle, I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT);
		break;
	default:
		abort();
	}

	gem_set_tiling(fd, handle, tiling, 512);

	if (dir == READ) {
		src = ptr;
		dst = buf;
	} else {
		src = buf;
		dst = ptr;
	}

	clock_gettime(CLOCK_MONOTONIC, &start);
	switch (dir) {
	case CLEAR:
	case FAULT:
		memset(dst, 0, OBJECT_SIZE);
		break;
	default:
		memcpy(dst, src, OBJECT_SIZE);
		break;
	}
	clock_gettime(CLOCK_MONOTONIC, &end);

	loops = 2 / elapsed(&start, &end);
	while (reps--) {
		clock_gettime(CLOCK_MONOTONIC, &start);
		for (c = 0; c < loops; c++) {
			int page;

			switch (dir) {
			case CLEAR:
				memset(dst, 0, OBJECT_SIZE);
				break;
			case FAULT:
				munmap(ptr, OBJECT_SIZE);
				switch (map) {
				case CPU:
					ptr = gem_mmap__cpu(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
					break;
				case GTT:
					ptr = gem_mmap__gtt(fd, handle, OBJECT_SIZE, PROT_WRITE);
					break;
				case WC:
					ptr = gem_mmap__wc(fd, handle, 0, OBJECT_SIZE, PROT_WRITE);
					break;
				default:
					abort();
				}
				for (page = 0; page < OBJECT_SIZE; page += 4096) {
					uint32_t *x = (uint32_t *)ptr + page/4;
					__asm__ __volatile__("": : :"memory");
					page += *x; /* should be zero! */
				}
				break;
			default:
				memcpy(dst, src, OBJECT_SIZE);
				break;
			}
		}
		clock_gettime(CLOCK_MONOTONIC, &end);
		printf("%7.3f\n", OBJECT_SIZE / elapsed(&start, &end) * loops / (1024*1024));
	}

	return 0;
}
Exemple #28
0
inline double secondsSince(CpuTimes const& since) {
  return seconds(elapsed(cpuTimesNow().wall, since.wall));
}
Exemple #29
0
bool SVGAnimationElement::beginElementAt(float offset, ExceptionCode &ec)
{
    addBeginTime(elapsed() + offset);
    return true;
}
Exemple #30
0
void Ramp::stop() {
	if (_isRunning) {
		_offsetTime = elapsed();
		_isRunning = false;
	}
}