Exemplo n.º 1
0
void
do_10_pack ()
{
  int n;
  long start = get_msec_count (), duration;

  ta_enter (&ten_pack_ta);
  for (n = 0; n < 10; n++)
    {
      new_order ();
#ifndef NO_ONLY
      payment ();
#endif
    }

#ifndef NO_ONLY
  ta_enter (&delivery_ta);
  if (strstr (dbms, "Virtuoso") || strstr (dbms, "SOAP"))
    {
      for (n = 1; n <= 10; n++)
	delivery_1 (local_w_id, n);
    }
  else
    {
      delivery_1 (local_w_id, 0);
    }
  ta_leave (&delivery_ta);
  slevel ();
  ostat ();
#endif

  ta_leave (&ten_pack_ta);
  duration = get_msec_count () - start;
#if defined(GUI)
  log (1, "-- %ld tpmC\n", 600000 / duration);
#else
  printf ("-- %ld tpmC\n\n", 600000 / duration);
  fflush (stdout);
#endif
}
Exemplo n.º 2
0
void
delivery ()
{

  int n;

  ta_enter (&delivery_ta);
  if (strstr (dbms, "Virtuoso"))
    {
      for (n = 1; n <= 10; n++)
	delivery_1 (local_w_id, n);
    }
  else
    {
      delivery_1 (local_w_id, 0);
    }
  ta_leave (&delivery_ta);
}
Exemplo n.º 3
0
void
t1_lines (t1_window_t * tw, int l1, int l2, int batch_sz)
{
  char head [100];
  timer_account_t ins_ta;
  int ctype = SQL_CURSOR_DYNAMIC;
  int inx, n;
  int rno = l1;
  char * text = T1_BASE_TEXT;

  sprintf (head, "ins %d into T1", batch_sz);
  ta_init (&ins_ta, head);
  QUIET;
  t1_window (tw, "CR1", hdbc1, text, ctype, 00, batch_sz, SQL_CONCUR_READ_ONLY, NULL);
  tw_fetch (tw, SQL_FETCH_NEXT, 0);
  inx = 0;
  for (rno = l1; rno < l2; rno++)
    {
      tw->tw_set[inx].t1_row_no = inx;
      tw->tw_set[inx].t1_row_no = rno;
      sprintf (tw->tw_set[inx].t1_string1, "%d", rno % 300);
      sprintf (tw->tw_set[inx].t1_string2, "%d", 300 - (rno % 300));
      tw->tw_set[inx].t1_fi2 = 11;
      strcpy (tw->tw_set[inx].t1_fs1, "ins");
      TW_DEFAULT_LEN (tw->tw_set[inx]);
      inx++;
      if (inx == batch_sz)
	{
	  ta_enter (&ins_ta);
	  tw_set_pos (tw, 0, SQL_ADD);
	  ta_leave (&ins_ta);
	  inx = 0;
	}
    }

  for (n = 0; n < inx; n++)
    tw_set_pos (tw, n + 1, SQL_ADD);
  tw_close (tw);
  QUIET_OFF;
  ta_print_out (stdout, &ins_ta);
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{
    char buffer[BUFSIZE];
    char result[BUFSIZE];
    char *dsn = getenv("DSN");
    char *uid = getenv("UID");
    char *pwd = getenv("PWD");

    if (SQL_SUCCESS != (rc = SQLAllocEnv (&henv)))
      {
	odbc_error ();
	return -1;
      }
    if (SQL_SUCCESS != (rc = SQLAllocConnect (henv, &hdbc)))
      {
	odbc_error ();
	return -1;
      }
    if (SQL_SUCCESS != (rc = SQLConnect (hdbc,
	    dsn ? dsn : "1111", SQL_NTS,
	    uid ? uid : "dba", SQL_NTS,
	    pwd ? pwd : "dba", SQL_NTS)))
      {
	odbc_error ();
	return -1;
      }
    if (SQL_SUCCESS != (rc = SQLAllocStmt (hdbc, &hstmt)))
      {
	odbc_error ();
	return -1;
      }
    while (NULL != fgets (buffer, BUFSIZE, stdin))
    {
      if (SQL_SUCCESS != (rc = SQLBindParameter (hstmt, 3, SQL_PARAM_OUTPUT,
	      SQL_C_CHAR, SQL_CHAR,
	      sizeof (result), 0, result, sizeof (result), NULL)))
	{
	  odbc_error ();
	  break;
	}

        if (0 == strncmp ("chdir", buffer, 5))
        {
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 1, SQL_C_CHAR, SQL_CHAR, 0, 0, replace_newline (buffer + 6), NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 2, SQL_C_CHAR, SQL_CHAR, 0, 0, "", NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLExecDirect (hstmt, "XSLT_CHDIR (?, ?, ?)", SQL_NTS)))
	    {
	      odbc_error ();
	      break;
	    }

            /*change directory:*/
	    printf ("%s\n", result);
            fflush (stdout);
        }
        else if (0 == strncmp ("stylesheet", buffer, 10))
        {
            /*load stylesheet: */

	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 1, SQL_C_CHAR, SQL_CHAR, 0, 0,
		  replace_newline (&buffer[11]), NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 2, SQL_C_CHAR, SQL_CHAR, 0, 0, "", NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLExecDirect (hstmt, "XSLT_STYLESHEET (?, ?, ?)", SQL_NTS)))
	    {
	      odbc_error ();
	      break;
	    }

	  printf ("%s\n", result);
	  fflush (stdout);
        }
        else if (0 == strncmp ("input", buffer, 5))
        {
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 1, SQL_C_CHAR, SQL_CHAR, 0, 0,
		  replace_newline (&buffer[6]), NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 2, SQL_C_CHAR, SQL_CHAR, 0, 0, "", NULL)))
	    {
	      odbc_error ();
	      break;
	    }

	  if (SQL_SUCCESS != (rc = SQLExecDirect (hstmt, "XSLT_INPUT (?, ?, ?)", SQL_NTS)))
	    {
	      odbc_error ();
	      break;
	    }

	  printf ("%s\n", result);
	  fflush (stdout);
        }
        else if (0 == strncmp ("transform", buffer, 9))
        {
            short iter = 1;
            char * c = buffer+10;
            char *filename;
	    timer_account_t ta;

            /* get output filename */
            while (*c != '\n' && *c != '\0' && *c != ' ')
            {
                c++;
            }
            if (*c == ' ')
            {
                *c = 0;
                c++;
                filename = buffer + 10;
            }

            /* get # of iterations */
            iter = atoi(c);
            if (iter <= 0)
              iter = 1;
/*            printf ("file: %s iter : %d buffer %s\n", filename, iter, buffer); */
	    ta_init (&ta, "test");
	    ta_enter (&ta);


	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 1, SQL_C_CHAR, SQL_CHAR, 0, 0,
		  filename, NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLSetParam (hstmt, 2, SQL_C_SHORT, SQL_INTEGER, 0, 0, &iter, NULL)))
	    {
	      odbc_error ();
	      break;
	    }
	  if (SQL_SUCCESS != (rc = SQLExecDirect (hstmt, "XSLT_TRANSFORM (?, ?, ?)", SQL_NTS)))
	    {
	      odbc_error ();
	      break;
	    }
	  ta_leave (&ta);

	  printf ("OK wallclock: %06ld ms; cpuclock: %06ld'\n", ta.ta_total, ta.ta_total);
	  fflush (stdout);
        }
        else if (0 == strncmp ("terminate", buffer, 9))
        {
            printf ("OK\n");
            break;
        }
	if (SQL_SUCCESS != (rc = SQLFreeStmt (hstmt, SQL_CLOSE)))
	  {
	    odbc_error ();
	    return -1;
	  }
	if (SQL_SUCCESS != (rc = SQLFreeStmt (hstmt, SQL_RESET_PARAMS)))
	  {
	    odbc_error ();
	    return -1;
	  }
    }

    if (SQL_SUCCESS != (rc = SQLFreeStmt (hstmt, SQL_DROP)))
      return -1;
    if (SQL_SUCCESS != (rc = SQLDisconnect (hdbc)))
      return -1;
    if (SQL_SUCCESS != (rc = SQLFreeConnect (hdbc)))
      return -1;
    if (SQL_SUCCESS != (rc = SQLFreeEnv (henv)))
      return -1;
    return 0;
}
Exemplo n.º 5
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;
}