예제 #1
0
/* ------------------------------------------------------------------ */
leap_table_t *
leapsec_get_table(
	int alternate)
{
	leap_table_t *p1, *p2;

	p1 = _lptr;
	if (p1 == &_ltab[0]) {
		p2 = &_ltab[1];
	} else if (p1 == &_ltab[1]) {
		p2 = &_ltab[0];
	} else {
		p1 = &_ltab[0];
		p2 = &_ltab[1];
		reset_times(p1);
		reset_times(p2);
		_lptr = p1;
	}
	if (alternate) {
		memcpy(p2, p1, sizeof(leap_table_t));
		p1 = p2;
	}

	return p1;
}
예제 #2
0
/* [internal] Add raw data to the table, removing old entries on the
 * fly. This cannot fail currently.
 */
static int/*BOOL*/
add_range(
	leap_table_t *      pt,
	const leap_info_t * pi)
{
	/* If the table is full, make room by throwing out the oldest
	 * entry. But remember the accumulated leap seconds!
	 */
	if (pt->head.size >= MAX_HIST) {
		pt->head.size     = MAX_HIST - 1;
		pt->head.base_tai = pt->info[pt->head.size].taiof;
	}

	/* make room in lower end and insert item */
	memmove(pt->info+1, pt->info, pt->head.size*sizeof(*pt->info)); 
	pt->info[0] = *pi;
	pt->head.size++;

	/* invalidate the cached limit data -- we might have news ;-)
	 *
	 * This blocks a spurious transition detection. OTOH, if you add
	 * a value after the last query before a leap transition was
	 * expected to occur, this transition trigger is lost. But we
	 * can probably live with that.
	 */
	reset_times(pt);
	return TRUE;
}
예제 #3
0
/* [internal] Add raw data to the table, removing old entries on the
 * fly. This cannot fail currently.
 */
static int/*BOOL*/
add_range(
	leap_table_t *      pt,
	const leap_info_t * pi)
{
	/* If the table is full, make room by throwing out the oldest
	 * entry. But remember the accumulated leap seconds! Likewise,
	 * assume a positive leap insertion if this is the first entry
	 * in the table. This is not necessarily the best of all ideas,
	 * but it helps a great deal if a system does not have a leap
	 * table and gets updated from an upstream server.
	 */
	if (pt->head.size == 0) {
		pt->head.base_tai = pi->taiof - 1;
	} else if (pt->head.size >= MAX_HIST) {
		pt->head.size     = MAX_HIST - 1;
		pt->head.base_tai = pt->info[pt->head.size].taiof;
	}

	/* make room in lower end and insert item */
	memmove(pt->info+1, pt->info, pt->head.size*sizeof(*pt->info));
	pt->info[0] = *pi;
	pt->head.size++;

	/* invalidate the cached limit data -- we might have news ;-)
	 *
	 * This blocks a spurious transition detection. OTOH, if you add
	 * a value after the last query before a leap transition was
	 * expected to occur, this transition trigger is lost. But we
	 * can probably live with that.
	 */
	reset_times(pt);
	return TRUE;
}
예제 #4
0
/* ---------------------------------------------------------------------
 * Clear all leap second data. Use it for init & cleanup
 */
void
leapsec_clear(
	leap_table_t * pt)
{
	memset(&pt->lsig, 0, sizeof(pt->lsig));
	memset(&pt->head, 0, sizeof(pt->head));
	reset_times(pt);
}
예제 #5
0
 void NewtonSolver<Scalar>::init_linear_solver()
 {
   // Set up the solver, jacobian, and residual according to the solver selection.
   jacobian = create_matrix<Scalar>(this->matrix_solver_type);
   residual = create_vector<Scalar>(this->matrix_solver_type);
   linear_solver = create_linear_solver<Scalar>(this->matrix_solver_type, jacobian, residual);
   reset_times();
   this->timer = NULL;
 }
예제 #6
0
/* ------------------------------------------------------------------ */
int/*BOOL*/
leapsec_electric(
	int/*BOOL*/ on)
{
	int res = _electric;
	if (on < 0)
		return res;

	_electric = (on != 0);
	if (_electric == res)
		return res;

	if (_lptr == &_ltab[0] || _lptr == &_ltab[1])
		reset_times(_lptr);

	return res;
}
예제 #7
0
파일: ntp_leapsec.c 프로젝트: ntpsec/ntpsec
/* ------------------------------------------------------------------ */
bool
leapsec_electric(
	electric_mode el)
{
	int res = _electric;
	if (el == electric_query)
		return res;

	_electric = (el == electric_on);
	if (_electric == res)
		return res;

	if (_lptr == &_ltab[0] || _lptr == &_ltab[1])
		reset_times(_lptr);

	return res;
}
예제 #8
0
/* Reset the current leap frame */
void
leapsec_reset_frame(void)
{
	reset_times(leapsec_get_table(FALSE));
}
예제 #9
0
파일: ntp_leapsec.c 프로젝트: ntpsec/ntpsec
/* Reset the current leap frame */
void
leapsec_reset_frame(void)
{
	reset_times(leapsec_get_table(false));
}
예제 #10
0
void
run_timed_test (int argc, char **argv)
{
  int i, n_rounds = atoi (argv[5]);
  if (strstr (dbms, "Virtuoso"))
    {
      new_order_text = new_order_text_kubl;
      payment_text = payment_text_kubl;
      delivery_text = delivery_text_kubl;
      slevel_text = slevel_text_kubl;
      ostat_text = ostat_text_kubl;
    }
  else if (strstr (dbms, "SQL Server"))
    {
      new_order_text = new_order_text_mssql;
      payment_text = payment_text_mssql;
      delivery_text = delivery_text_mssql;
      slevel_text = slevel_text_mssql;
      ostat_text = ostat_text_mssql;
    }
  else if (strstr (dbms, "Oracle"))
    {
      new_order_text = new_order_text_ora;
      payment_text = payment_text_ora;
      delivery_text = delivery_text_ora;
      slevel_text = slevel_text_ora;
      ostat_text = ostat_text_ora;
    }
  else
    {
      printf ("Unknown DBMS %s\n", dbms);
      exit (-1);
    }
  if (argc == 8)
    {
      local_w_id = atoi (argv[6]);
      n_ware = atoi (argv[7]);
    }
  reset_times ();

  for (i = 0; i < n_rounds; i++)
    {
      int n;
      long start, duration;

      start = get_msec_count ();
      for (n = 0; n < 10; n++)
	{
	  transaction_per_period (TEN_PACK_TIME / 23, new_order);
	  transaction_per_period (TEN_PACK_TIME / 23, payment);
	}

      transaction_per_period (TEN_PACK_TIME / 23, delivery);
      transaction_per_period (TEN_PACK_TIME / 23, slevel);
      transaction_per_period (TEN_PACK_TIME / 23, ostat);

      duration = (get_msec_count () - start) / 1000;
      if (TEN_PACK_TIME - duration > 0)
#ifdef WIN32
	Sleep ((TEN_PACK_TIME - duration) * 1000);
#else
	sleep (TEN_PACK_TIME - duration);
#endif
      print_times ();
      if (i && 0 == i % 10)
	{
	  reset_times ();
	}
    }
}
예제 #11
0
int
do_run_test (int n_rounds, int _local_w_id, int _n_ware)
{
  int i;
  long start_check_point = get_msec_count (), check_point;
  long start_total = get_msec_count (), total;
  if (strstr (dbms, "Virtuoso"))
    {
      new_order_text = new_order_text_kubl;
      payment_text = payment_text_kubl;
      delivery_text = delivery_text_kubl;
      slevel_text = slevel_text_kubl;
      ostat_text = ostat_text_kubl;
    }
  else if (strstr (dbms, "SQL Server"))
    {
      new_order_text = new_order_text_mssql;
      payment_text = payment_text_mssql;
      delivery_text = delivery_text_mssql;
      slevel_text = slevel_text_mssql;
      ostat_text = ostat_text_mssql;
    }
  else if (strstr (dbms, "Oracle"))
    {
      new_order_text = new_order_text_ora;
      payment_text = payment_text_ora;
      delivery_text = delivery_text_ora;
      slevel_text = slevel_text_ora;
      ostat_text = ostat_text_ora;
    }
  else if (strstr (dbms, "SOAP"))
    {
      new_order_text = new_order_text_SOAP;
      payment_text = payment_text_SOAP;
      delivery_text = delivery_text_SOAP;
      slevel_text = slevel_text_SOAP;
      ostat_text = ostat_text_SOAP;
    }
  else
    {
      return 0;
    }
  if (_local_w_id != -1)
    {
      local_w_id = _local_w_id;
      n_ware = _n_ware;
    }
  reset_times ();

#ifdef GUI
  set_progress_max (n_rounds);
#endif
  ta_init (&total_ta, "TOTAL");
  ta_init (&check_point_ta, "CHECK_POINT");
  ta_enter (&total_ta);
  ta_enter (&check_point_ta);
  for (i = 0; i < n_rounds; i++)
    {
      do_10_pack ();
      if (i && 0 == i % SAMPLE_CHECK)
	{
	  check_point = get_msec_count () - start_check_point;
	  total = get_msec_count () - start_total;
	  printf
	      ("# Transaction No:%d Last cycle:%ld tpmC  From start:%ld tpmC\n", \
	      i, 600000 / (check_point / SAMPLE_CHECK),
	      600000 / (total / i));
	  ta_init (&check_point_ta, "CHECK_POINT");
	  /*Do statistic */
	}
#if 0
      /* not the client's problem during test run */
      if (i && 0 == i % CHECK_POINT_INTERVAL)
	scrap_log ();
#endif
      if (i && 0 == i % 10)
	{
#if !defined(GUI)
	  print_times ();
	  reset_times ();
#endif
	}
#if defined(GUI)
      progress (i);
#endif
    }
#if defined(GUI)
  progress_done ();
#endif
  total = get_msec_count () - start_total;
  printf ("# Total transactions:%d %ld tpmC, %d retries\n", i, 600000 / (total / i), n_deadlocks);

  return 1;
}
예제 #12
0
static int
ThreadedCalcStats (OList * tests, THREAD_T ** workers,
    test_t ** data, int nConnCount, int *nThreads)
{
  OList *iter;
  int nConn;
  int rc = 1;
  int rc1 = 1;

  for (iter = tests, nConn = 0; iter && nConn < nConnCount;
      nConn++, iter = o_list_next (iter))
    {
      int nOkA = 0, nOkC = 0;
      int nA = 0, nC = 0;
#if defined(PTHREADS)
      unsigned long result;
#elif defined(WIN32)
      unsigned int result;
#endif
      BOOL runStatus = TRUE;
      int i;
      test_t *test = (test_t *) iter->data;
      if (IS_A (*test))
	{
	  test->tpc.a.nTrnCnt = 0;
	  test->tpc.a.nTrnCnt1Sec = 0;
	  test->tpc.a.nTrnCnt2Sec = 0;
	  test->tpc.a.dDiffSum = -1;
	}
      else
	{
	  test->tpc.c.tpcc_sum = 0;
	  test->tpc.c.run_time = 0;
	  test->tpc.c.nRounds = 0;
	  reset_times (test);
	}

      for (i = 0; i < nThreads[nConn]; i++)
	{
	  GET_EXIT_STATUS (workers[nConn][i], &result);

	  if (!result)
	    runStatus = result;

	  switch (data[nConn][i].TestType)
	    {
	    case TPC_A:
	      nA++;
	      if (!test->is_unsupported && result)
		{
		  nOkA++;
		  test->tpc.a.nTrnCnt += data[nConn][i].tpc.a.nTrnCnt;
		  test->tpc.a.nTrnCnt1Sec += data[nConn][i].tpc.a.nTrnCnt1Sec;
		  test->tpc.a.nTrnCnt2Sec += data[nConn][i].tpc.a.nTrnCnt2Sec;
		  if (data[nConn][i].tpc.a.dDiffSum > test->tpc.a.dDiffSum)
		    test->tpc.a.dDiffSum = data[nConn][i].tpc.a.dDiffSum;
		}
	      break;

	    case TPC_C:
	      nC++;
	      if (result)
		{
		  nOkC++;
		  test->tpc.c.tpcc_sum += data[nConn][i].tpc.c.tpcc_sum;
		  test->tpc.c.run_time += data[nConn][i].tpc.c.run_time;
		  test->tpc.c.nRounds += data[nConn][i].tpc.c.nRounds;

		  /* individual transaction timings */
		  ta_merge (&(test->tpc.c.ten_pack_ta),
		      &(data[nConn][i].tpc.c.ten_pack_ta));
		  ta_merge (&(test->tpc.c.new_order_ta),
		      &(data[nConn][i].tpc.c.new_order_ta));
		  ta_merge (&(test->tpc.c.payment_ta),
		      &(data[nConn][i].tpc.c.payment_ta));
		  ta_merge (&(test->tpc.c.delivery_ta),
		      &(data[nConn][i].tpc.c.delivery_ta));
		  ta_merge (&(test->tpc.c.slevel_ta),
		      &(data[nConn][i].tpc.c.slevel_ta));
		  ta_merge (&(test->tpc.c.ostat_ta),
		      &(data[nConn][i].tpc.c.ostat_ta));
		}
	      break;
	    }
	}

      if (nA || nOkC)
	rc1 = do_login (test);

      if (nA)
	{
	  if (nOkA < nA)
	    pane_log
		("\r\n\r\n%s - %s(%s) - %d out of %d TPC-A Threads ended with errors.\r\n",
		test->szName, test->szDBMS, test->szDriverName, nA - nOkA,
		nA);
	  else
	    pane_log
		("\r\n\r\n%s - %s(%s) - all %d TPC-A Threads completed successfully.\r\n",
		test->szName, test->szDBMS, test->szDriverName, nOkA);

	  if (nOkA == 0 && !test->szSQLState[0] && !test->szSQLError[0])
	    {
	      strcpy ((char *) test->szSQLState, "ERROR");
	      strcpy ((char *) test->szSQLError,
		  "All Threads ended prematurely.");
	    }

	  if (test->hdbc)
	    CalcStats (runStatus, nOkA, test, test->tpc.a.nTrnCnt,
		test->tpc.a.nTrnCnt1Sec,
		test->tpc.a.nTrnCnt2Sec, test->tpc.a.dDiffSum);
	}

      if (nOkC)
	{
	  pane_log
	      ("\r\n\r\n%s - %s(%s) - %d/%d TPC-C Threads ended with no errors.\r\n",
	      test->szName, test->szDBMS, test->szDriverName, nOkC, nC);
	  test->tpc.c.run_time /= nOkC;
	  if (test->hdbc)
	    add_tpcc_result (test);
	}

      if ((nA || nOkC) && rc1)
	do_logout (test);

      if (!(nOkA || nOkC))
	{
	  pane_log
	      ("\r\n\r\n%s - %s(%s) - All Threads ended prematurely.\r\n",
	      test->szName, test->szDBMS, test->szDriverName);
	  rc = 0;
	}
    }
  return rc;
}