Ejemplo n.º 1
0
Archivo: subp.c Proyecto: flavioc/XSB
/*
 * Called through builtins statistics/1 and statistics/0.
 * ( statistics :- statistics(1). )
 */
void print_statistics(CTXTdeclc int amount) {

  switch (amount) {

  case 0:		    /* Reset Statistical Parameters */
#ifndef MULTI_THREAD
    realtime_count_gl = real_time();
    perproc_reset_stat();	/* reset op-counts, starting time, and 'tds'
				   struct variable (all 0's) */
    reset_stat_total(); 	/* reset 'ttt' struct variable (all 0's) */
    xsb_mesg("Statistics is reset.");
    break;
#else
    realtime_count_gl = real_time();
    break;
#endif

  case 1:		    /* Default use: Print Stack Usage and CPUtime: */
    perproc_stat();		/* move max usage into 'ttt' struct variable */
    total_stat(CTXTc real_time()-realtime_count_gl);   /* print */
    reset_stat_total(); 	/* reset 'ttt' struct variable (all 0's) */
    break;

  case 2:		    /* Print Detailed Table Usage */
    print_detailed_tablespace_stats(CTXT);
    break;

  case 3:		    /* Print Detailed Table, Stack, and CPUtime */
#ifndef MULTI_THREAD
    perproc_stat();
    total_stat(CTXTc real_time()-realtime_count_gl);
    reset_stat_total();
    print_detailed_tablespace_stats(CTXT);
    print_detailed_subsumption_stats();
    break;
#else
    fprintf(stdwarn,"statistics(3) not yet implemented for MT engine\n");
    break;
#endif
  case 4:                  /* mutex use (if PROFILE_MUTEXES is defined) */
    print_mutex_use();
    print_mem_allocs();
    break;
  case 5:
    dis(0); 
    break;		/* output memory image - data only; for debugging */
  case 6:
    dis(1); 
    break;		/* output memory image - data + text; for debugging */
#ifdef CP_DEBUG
  case 7:
    print_cp_backtrace();
    break;
#endif
  case 8:              /* print symbol/string statistics */
    symbol_table_stats();
    string_table_stats();
    break;
  }
}
Ejemplo n.º 2
0
/*
 * Called through builtins statistics/1 and statistics/0.
 * ( statistics :- statistics(1). )
 */
void print_statistics(CTXTdeclc int choice) {

  switch (choice) {

  case STAT_RESET:		   
#ifndef MULTI_THREAD
    realtime_count_gl = real_time();
    reset_stat_counters();	/* reset op-counts */
    break;
#else
    realtime_count_gl = real_time();
    break;
#endif

  case STAT_DEFAULT:		    /* Default use: Print Stack Usage and CPUtime: */
#ifndef MULTI_THREAD
    cputime_count_gl = (cpu_time() - time_start_gl);
#endif
    total_stat(CTXTc real_time()-realtime_count_gl);   /* print */
    break;

  case STAT_TABLE:		    /* Print Detailed Table Usage */
    print_detailed_tablespace_stats(CTXT);
    break;

  case 3:		    /* Print Detailed Table, Stack, and CPUtime */
#ifndef MULTI_THREAD
    cputime_count_gl += (cpu_time() - time_start_gl);
    total_stat(CTXTc real_time()-realtime_count_gl);
    print_detailed_tablespace_stats(CTXT);
    print_detailed_subsumption_stats();
    break;
#else
    fprintf(stdwarn,"statistics(3) not yet implemented for MT engine\n");
    break;
#endif
  case STAT_MUTEX:                  /* mutex use (if PROFILE_MUTEXES is defined) */
    print_mutex_use();
    print_mem_allocs("stat_mutex");
    break;
  case 5:
    dis(0); 
    break;		/* output memory image - data only; for debugging */
  case 6:
    dis(1); 
    break;		/* output memory image - data + text; for debugging */
#ifdef CP_DEBUG
  case 7:
    print_cp_backtrace();
    break;
#endif
  case STAT_ATOM:              /* print symbol/string statistics */
    symbol_table_stats();
    string_table_stats();
    break;
  }
}
Ejemplo n.º 3
0
/// Replacement time().
time_t time(time_t* v) throw ()
{
  time_t rt;

  if (!real_time)
  {
    real_time = (time_t (*)(time_t*))(intptr_t)dlsym(RTLD_NEXT, "time");
  }

  pthread_mutex_lock(&time_lock);

  if (completely_control_time)
  {
    rt = abs_time;
  }
  else
  {
    // Get the real time in seconds since the epoch.
    rt = real_time(NULL);
  }

  // Add the seconds portion of the time offset.
  rt += time_offset.tv_sec;
  pthread_mutex_unlock(&time_lock);

  if (v != NULL)
  {
    // Pointer supplied, so set it to the returned value.
    *v = rt;
  }

  return rt;
}
Ejemplo n.º 4
0
void cwtest_completely_control_time()
{
  if (!real_clock_gettime)
  {
    real_clock_gettime = (int (*)(clockid_t, struct timespec *))(intptr_t)dlsym(RTLD_NEXT, "clock_gettime");
  }

  if (!real_time)
  {
    real_time = (time_t (*)(time_t*))(intptr_t)dlsym(RTLD_NEXT, "time");
  }

  pthread_mutex_lock(&time_lock);
  completely_control_time = true;

  // Store the time at which the test scripts took control.  Do this for both
  // clock_gettime() and time().
  struct timespec ts;
  for (unsigned int i = 0;
       i < (sizeof(supported_clock_ids) / sizeof(supported_clock_ids[0]));
       ++i)
  {
    clockid_t clock_id = supported_clock_ids[i];
    real_clock_gettime(clock_id, &ts);
    abs_timespecs[clock_id] = ts;
  }

  abs_time = real_time(NULL);

  pthread_mutex_unlock(&time_lock);
}
Ejemplo n.º 5
0
static int torch_lua_toc(lua_State* L)
{
  double toctime = real_time();
  lua_Number tictime = luaL_checknumber(L,1);
  lua_pushnumber(L,toctime-tictime);
  return 1;
}
Ejemplo n.º 6
0
TEST_F( TimeTests, TimeUtils_Convert_Seconds_To_RealTicks )
{
	STickTime real_time( 5000000 );
	double real_time_seconds = CPlatformTime::Convert_High_Resolution_Time_To_Seconds( real_time.Get_Ticks() );

	ASSERT_TRUE( NTimeUtils::Convert_Seconds_To_High_Resolution_Ticks( real_time_seconds ) == real_time );
	ASSERT_TRUE( NTimeUtils::Convert_Seconds_To_Ticks( TT_REAL_TIME, real_time_seconds ) == real_time );
}
Ejemplo n.º 7
0
void  get_statistics(CTXTdecl) {
  int type;
  type = ptoc_int(CTXTc 3);
  switch (type) {
// runtime [since start of Prolog,since previous statistics] 
// CPU time used while executing, excluding time spent
// garbage collecting, stack shifting, or in system calls. 
  case RUNTIME: {
    double tot_cpu, incr_cpu;

    tot_cpu = cpu_time();
    incr_cpu = tot_cpu - last_cpu;
    last_cpu = tot_cpu;
    //    tds.time_count = incr_cpu - time_start;
    //    reset_stat_total(); 	/* reset 'ttt' struct variable (all 0's) */

    ctop_float(CTXTc 4, tot_cpu);
    ctop_float(CTXTc 5, incr_cpu);
    break;
  }
  case WALLTIME: {
    double tot_wall,this_wall,incr_wall;

    this_wall = real_time();
    tot_wall = this_wall - realtime_count_gl;

    if (!last_wall) last_wall = realtime_count_gl;
    incr_wall = this_wall - last_wall;
    last_wall = this_wall;

    ctop_float(CTXTc 4, tot_wall);
    ctop_float(CTXTc 5, incr_wall);
    break;
      }
  case SHARED_TABLESPACE: 
    {
#ifdef MULTI_THREAD
	statistics_inusememory(CTXTc type);
#else
	xsb_abort("statistics/2 with parameter shared_tables not supported in this configuration\n");
#endif 
	break;
      }
  default: {
      statistics_inusememory(CTXTc type);
      break;
    }

  }
}
Ejemplo n.º 8
0
time_t time(time_t *t)
{
	init_shared_memory_if_needed();
	/* If the current_sim pointer is NULL that means that there is no
	 * shared memory segment, at least not yet, therefore use real function
	 * for now.
	 * Note, here we are examing the location of to where the pointer points
	 *       and not the value itself.
	 */
	if (!(current_sim) && !real_time) init_funcs();
	if (!(current_sim)) {
		return real_time(t);
	} else {
		if(t) {
			*t = *(current_sim);}
		return *(current_sim);
	}
}
Ejemplo n.º 9
0
TerrainSection build_section_from_region(UserInterface *ui,
                                         ClientRegion *rgn)
{
  MeshAccumulator *ma = new MeshAccumulator();
  uint64_t t0 = real_time();

  for (int y=0; y<REGION_SIZE; y++) {
    for (int x=0; x<REGION_SIZE; x++) {
      std::vector<Span>& col = rgn->columns[y][x];
      //printf("build mesh (%d,%d) %lu spans: ", rgn->origin.x + x, rgn->origin.y + y, col.size());
      std::vector<Span> *col_e = NULL;
      std::vector<Span> *col_ne = NULL;
      std::vector<Span> *col_nw = NULL;
      std::vector<Span> *col_w = NULL;
      std::vector<Span> *col_sw = NULL;
      std::vector<Span> *col_se = NULL;

      if (x > 0) {
        col_w = &rgn->columns[y][x-1];
        //printf(" W");
      }
      if (x < (REGION_SIZE-1)) {
        col_e = &rgn->columns[y][x+1];
        //printf(" E");
      }
      if (y > 0) {
        {
          int se_x = x, se_y = y;
          hex_se(&se_x, &se_y);
          if (se_x < REGION_SIZE) {
            assert(se_y >= 0);
            assert(se_x >= 0);
            col_se = &rgn->columns[se_y][se_x];
            //printf(" SE");
          }
        }
        {
          int sw_x = x, sw_y = y;
          hex_sw(&sw_x, &sw_y);
          if (sw_x > 0) {
            assert(sw_y >= 0);
            assert(sw_x < REGION_SIZE);
            col_sw = &rgn->columns[sw_y][sw_x];
            //printf(" SW");
          }
        }
      }
      if (y < (REGION_SIZE-1)) {
        {
          int ne_x = x, ne_y = y;
          hex_ne(&ne_x, &ne_y);
          if (ne_x < REGION_SIZE) {
            assert(ne_y >= 0);
            assert(ne_x >= 0);
            col_ne = &rgn->columns[ne_y][ne_x];
            //printf(" NE");
          }
        }

        {
          int nw_x = x, nw_y = y;
          hex_nw(&nw_x, &nw_y);
          if (nw_x > 0) {
            assert(nw_y >= 0);
            assert(nw_x < REGION_SIZE);
            col_nw = &rgn->columns[nw_y][nw_x];
            //printf(" NW");
          }
        }
      }
      //printf("\n");

      //printf("bmr (%d,%d)  %u\n", x, y, ma->size());
      Slab s;
      s.x = rgn->origin.x + x;
      s.y = rgn->origin.y + y;
      s.z0 = rgn->basement;
      bool wantbottom = false;

      for (std::vector<Span>::iterator i=col.begin(); i<col.end(); ++i) {
        s.z1 = s.z0 + i->height;
        s.type = i->type;
        s.flags = i->flags;
        if (i->type == 240) {
          // special handling for water
          ma->setup(&s);
          ma->water_top();
        } else if (i->type != 0) {
          ma->setup(&s);
          ma->hextop();
          if (wantbottom) {
            ma->hexbottom();
          }
          if (!col_sw) {
            ma->face(0);
          }
          if (!col_se) {
            ma->face(1);
          }
          if (!col_e) {
            ma->face(2);
          }
          if (!col_ne) {
            ma->face(3);
          }
          if (!col_nw) {
            ma->face(4);
          }
          if (!col_w) {
            ma->face(5);
          }
        }
        s.z0 = s.z1;
        wantbottom = true;
      }
      if (col_sw) {
        explosive_merge(rgn, col, *col_sw, ma, rgn->origin.x + x, rgn->origin.y + y, 0);
      }
      if (col_se) {
        explosive_merge(rgn, col, *col_se, ma, rgn->origin.x + x, rgn->origin.y + y, 1);
      }
      if (col_e) {
        explosive_merge(rgn, col, *col_e, ma, rgn->origin.x + x, rgn->origin.y + y, 2);
      }
      if (col_ne) {
        explosive_merge(rgn, col, *col_ne, ma, rgn->origin.x + x, rgn->origin.y + y, 3);
      }
      if (col_nw) {
        explosive_merge(rgn, col, *col_nw, ma, rgn->origin.x + x, rgn->origin.y + y, 4);
      }
      if (col_w) {
        explosive_merge(rgn, col, *col_w, ma, rgn->origin.x + x, rgn->origin.y + y, 5);
      }
    }
  }

  TriangularMesh *m = ma->make_triangular(&ui->terrainShader);
  Mesh *tm = ma->make_transparent_triangular(&ui->waterShader, m);
  delete ma;
  uint64_t t1 = real_time();
  // report it as slow if it takes longer than 100 ms
  if ((t1-t0) > 100000) {
    fprintf(stderr, "warning: slow build for region (%d,%d); %d+%d triangles in %.4f sec\n", 
            rgn->origin.x, rgn->origin.y,
            m->count, tm ? tm->count : 0, 
            (t1-t0) * 1.0e-6);
  }
  rgn->picker = makeRegionPicker(rgn);

  TerrainSection s;
  s.ts_posn = rgn->origin;
  s.ts_ground = m;
  s.ts_water = tm;
  return s;
}
Ejemplo n.º 10
0
static int torch_lua_tic(lua_State* L)
{
  double ttime = real_time();
  lua_pushnumber(L,ttime);
  return 1;
}
Ejemplo n.º 11
0
Archivo: subp.c Proyecto: flavioc/XSB
/*
 * Called through builtin statistics/2.
 */
void statistics_inusememory(CTXTdeclc int type) {
  perproc_stat();		/* move max usage into 'ttt' struct variable */
    stat_inusememory(CTXTc real_time()-realtime_count_gl,type);   /* collect */
  reset_stat_total(); 	/* reset 'ttt' struct variable (all 0's) */
}
Ejemplo n.º 12
0
void  get_statistics(CTXTdecl) {
  int type;
  type = (int)ptoc_int(CTXTc 3);
  switch (type) {
// runtime [since start of Prolog,since previous statistics] 
// CPU time used while executing, excluding time spent
// garbage collecting, stack shifting, or in system calls. 
  case RUNTIME: {
    double tot_cpu, incr_cpu;

    tot_cpu = cpu_time();
    incr_cpu = tot_cpu - last_cpu;
    last_cpu = tot_cpu;

    ctop_float(CTXTc 4, tot_cpu);
    ctop_float(CTXTc 5, incr_cpu);
    break;
  }
  case WALLTIME: {
    double tot_wall,this_wall,incr_wall;

    this_wall = real_time();
    tot_wall = this_wall - realtime_count_gl;

    if (!last_wall) last_wall = realtime_count_gl;
    incr_wall = this_wall - last_wall;
    last_wall = this_wall;

    ctop_float(CTXTc 4, tot_wall);
    ctop_float(CTXTc 5, incr_wall);
    break;
      }
  case SHARED_TABLESPACE: 
    {
#ifdef MULTI_THREAD
	get_memory_statistics(CTXTc type);
#else
	xsb_abort("statistics/2 with parameter shared_tables not supported in this configuration\n");
#endif 
	break;
      }
  case IDG_COUNTS: {
    ctop_int(CTXTc 4,current_call_node_count_gl);
    ctop_int(CTXTc 5,current_call_edge_count_gl);
    break;
  }

  case TABLE_OPS: {
    UInteger ttl_ops = ans_chk_ins + NumSubOps_AnswerCheckInsert,
	 	 ttl_ins = ans_inserts + NumSubOps_AnswerInsert;
    ctop_int(CTXTc 4,NumSubOps_CallCheckInsert);
    ctop_int(CTXTc 5,NumSubOps_ProducerCall);
    ctop_int(CTXTc 6,var_subg_chk_ins_gl);
    ctop_int(CTXTc 7,var_subg_inserts_gl);
    ctop_int(CTXTc 8,ttl_ops);
    ctop_int(CTXTc 9,ttl_ins);


  }
  default: {
      get_memory_statistics(CTXTc type);
      break;
    }

  }
}
Ejemplo n.º 13
0
void init_statistics(void)
{
  realtime_count_gl = real_time();
  reset_stat_counters();   /* init statistics. structures */
  time_start_gl = 0;
}
Ejemplo n.º 14
0
void get_memory_statistics(CTXTdeclc int type) {
#ifndef MULTI_THREAD
  cputime_count_gl = (cpu_time() - time_start_gl);
#endif
  get_memory_statistics_1(CTXTc real_time()-realtime_count_gl,type);   /* collect */
}