如何利用loadrunner做mysql压力测试(2)

发表于:2011-08-31来源:未知作者:领测软件测试网采编点击数: 标签:loadrunner
lr_log_message(%s,sql); mysql_query(db, sql); results2 = mysql_store_result(db); while((record = mysql_fetch_row(results2))) { lr_log_message(count = %d, record[0]); } mysql_free_result(results2); pag

  lr_log_message("%s",sql);

  mysql_query(db, sql);

  results2 = mysql_store_result(db);

  while((record = mysql_fetch_row(results2)))

  {

  lr_log_message("count = %d", record[0]);

  }

  mysql_free_result(results2);

  page = count/10;

  lr_log_message("page = %d", page);

  for(j=0;j< =page;j++)

  {

  sprintf(sql, "SELECT * FROM posts_jx3 WHERE tid = %d LIMIT %d,10;",r2,j);

  lr_log_message("%s", sql);

  mysql_query(db, sql);

  if (j>0) {

  results2 = mysql_store_result(db);

  while((record = mysql_fetch_row(results2)))

  {

  lr_log_message("pid = %d", record[0]);

  }

  mysql_free_result(results2);

  }

  }

  }

  mysql_free_result(results2);

  return 0;

  }

  int my_mysql_insert()

  {

  int t;

  char sql[500];

  MYSQL_RES *results3;

  sprintf(sql,"%s","INSERT INTO posts_jx3 ( fid, tid, first, author, authorid, subject, dateline, message, useip, invisible, anonymous, usesig, htmlon, bbcodeoff, smileyoff, parseurloff, attachment, rate, ratetimes, status) VALUES ( 12345, 215053, 0, 'fdsafsdfsd', 2265065, '', 1240535917, 'fdsfsdfdsfd', '118.239.49.229', 0, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0);");

  lr_log_message("%s", sql);

  t = mysql_query(db, sql);

  if(t)

  {

  lr_log_message("%s", mysql_error(db));

  }

  else

  {

  lr_log_message("%s", "suc");

  }

  } 

原文转自:http://www.ltesting.net