Since the project initial test plan did not involve the performance test of MySQL, but only for the front end and load performance testing, and then on the line after the emergence of a variety of MySQL deadlock and other issues. Just after the project 1, there are empty files, you can study the performance test about MySQL. This issue also only records the steps of MySQL connection and SQL transaction submission through the LoadRunner official library, and the real performance test has not yet started. (In fact, is not the beginning, novice to the database performance test is still very vacant AH ~ ~ ~)
1. LoadRunner's Mysqllib library
: http://down.51cto.com/data/403722
Installation steps: Unzip the file and overwrite the bin and include files to the LoadRunner root directory;
library function files: ptt_mysql.h file;
Calling function: Lr_mysql_connect (); Lr_mysql_query (); Lr_mysql_disconnect ();
2. Code Implementation
Vuser_init:
#define MySQLServer "*******"//mysql server Ip#define mysqlusername "* * * *" //mysql user name # define MYSQLPASSWORD "* * * *" //mysql Password # mysqldb "******"//mysql database name # define MYSQLPORT "* * *"//mysql port # include "ptt_mysql.h"// Import library file Vuser_init () {return 0;}
Action:
{char chquery[128];int resultvalue; MYSQL *mconn;lr_load_dll ("Libmysql.dll"); Mconn = Lr_mysql_connect (Mysqlserver,mysqlusername,mysqlpassword,mysqldb,atoi (Mysqlport)); strcpy (ChQuery, "INSERT Into ' Netbarapppolicys '. ' Dbsyncinfo ' (syncversion) VALUES (' 112 '); "); Lr_start_transaction ("Insert"); resultvalue = Lr_mysql_query (Mconn, chquery); Execute the SQL statement if (Resultvalue! = 0) {lr_end_transaction ("Insert", Lr_fail);} else {lr_end_transaction ("Insert", Lr_pass);} Lr_mysql_disconnect (mconn); return 0;}
3. Note
Let your MySQL allow other PCs to connect as root. Command: grant all on * * to ' root ' @ ' IP ' identified by ' password ';
Using Lib Library to implement LoadRunner test MySQL performance