Beispiel #1
0
static void
collectLocalMemoryStats(QueryDesc *queryDesc, int eflags)
{
	BackendMemoryStat			*myStat;
	MemoryContextIteratorState	state;

	if (prev_ExecutorStart)
		prev_ExecutorStart(queryDesc, eflags);
	else
		standard_ExecutorStart(queryDesc, eflags);

	if (MyBackendProcNo < 0)
	{
		on_proc_exit(cleanupMyStat, 0);
		MyBackendProcNo = MyProc->pgprocno;
		Assert(MyBackendProcNo >= 0);
	}

	if (checkTick() == false)
		return;

	Assert(MyBackendProcNo < PROCARRAY_MAXPROCS);
	myStat = NthBMS(MyBackendProcNo);

	/*
	 * do not wait if reader currently locks our slot
	 */
	if (LWLockConditionalAcquire(myStat->lock, LW_EXCLUSIVE) == false)
		return;

	myStat->pid = MyProc->pid;
	myStat->nContext = 0;
	state.context = TopMemoryContext;
	state.level = 0;

	/*
	 * walk through all memory context and fill stat table in shared memory
	 */
	do {
		MemoryContextStat	*mcs = myStat->stats + myStat->nContext;
		int					namelen = strlen(state.context->name);

		if (namelen > NAMEDATALEN - 1)
			namelen = NAMEDATALEN - 1;
		memcpy(mcs->name.data, state.context->name, namelen);
		mcs->name.data[namelen] = '\0';

		mcs->level = state.level;

		getMemoryContextStat(state.context, &mcs->stat);
		myStat->nContext++;

		iterateMemoryContext(&state);
	} while (state.context && myStat->nContext < N_MC_STAT);

	LWLockRelease(myStat->lock);
}
Beispiel #2
0
void zTCPTask::checkSignal(const zRTime &ct)
{
	///Zebra::logger->debug("zTCPTask::checkSignal");
	if (ifCheckSignal() && checkInterval(ct))
	{
		if (checkTick())
		{
			//测试信号在指定时间范围内没有返回
			Zebra::logger->error("套接口检查测试信号失败");
			Terminate(zTCPTask::terminate_active);
		}
		else
		{
			//发送测试信号
			Cmd::t_NullCmd tNullCmd;
			//Zebra::logger->debug("服务端发送测试信号");
			if (sendCmd(&tNullCmd,sizeof(tNullCmd)))
				setTick();
		}
	}
}
Beispiel #3
0
void cStream::runChecks()
{
  register int j;

  /* --- SETUP --- determine precision and check timing --- */
  cout << HLINE
       << "STREAM version $Revision: 5.8 $"
       << endl
       << HLINE ;
  BytesPerWord = sizeof(double);
  cout << "This system uses "
       << BytesPerWord
       << " bytes per DOUBLE PRECISION word."
       << endl
       << HLINE
       << "Array size = "
       << N
       << ", Offset = "
       << OFFSET
       << endl
       << "Total memory required = "
       << ( 3.0 * BytesPerWord ) * ( ( double )N / 1048576.0 )
       << " MB."
       << endl
       << "Each test is run "
       << NTIMES
       << " times, but only"
       << endl
       << "the *best* time for each is used."
       << endl
       << HLINE;

    /* Get initial value for system clock. */
  for (j=0; j<N; j++)
  {
	  a[j] = 1.0;
	  b[j] = 2.0;
	  c[j] = 0.0;
	}

  cout << HLINE;

#ifdef vs2005
  cout << "Timer frequency (Hz): " << freq << endl;
  quantum = checkTick();
#else
  cout << "Timer frequency (Hz): " << CLOCKS_PER_SEC << endl;
  quantum = checkTick();
#endif

  if( quantum >= 1 )
  {
	  cout << "Your clock granularity/precision appears to be "
         << quantum
         << " microseconds."
         << endl;
  }
  else
  {
	  cout << "Your clock granularity appears to be "
	       << "less than one microsecond."
         << endl;
	  quantum = 1;
  }

  QueryPerformanceCounter( ( LARGE_INTEGER *)&start );
  for (j = 0; j < N; j++)
  {
    a[j] = 2.0E0 * a[j];
  }
  QueryPerformanceCounter( ( LARGE_INTEGER *)&stop );
  t = 1.0E6 * ( stop - start ) / freq;

  cout << "Each test below will take on the order of "
       << ( int )t
       << " microseconds."
       << endl
       << "   (= "
       << ( int )( t / quantum )
       << " clock ticks)"
       << endl
       << "Increase the size of the arrays if this shows that"
       << endl
       << "you are not getting at least 20 clock ticks per test."
       << endl
       << HLINE
       << "WARNING -- The above is only a rough guideline."
       << endl
       << "For best results, please be sure you know the"
       << endl
       << "precision of your system timer."
       << endl
       << HLINE;
} // void cStream::runChecks()