标题: 运用LOADRUNNER .NET ADD-IN 写的性能测试脚本 [打印本页] 作者: fish_yy 时间: 2007-12-9 11:04 标题: 运用LOADRUNNER .NET ADD-IN 写的性能测试脚本 运用LOADRUNNER .NET ADD-IN 写的性能测试脚本
using System;
using System.Runtime.InteropServices;
using System.Data.OleDb;
using System.Data;
namespace LoadRunnerUser1
{
/// <summary>
/// Summary description for VuserClass.
/// </summary>
[ClassInterface(ClassInterfaceType.AutoDual)]
public class VuserClass
{
LoadRunner.LrApi lr;
public VuserClass()
{
// LoadRunner Standard API Interface :: DO NOT REMOVE!!!
lr = new LoadRunner.LrApi();
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Initialize()
{
// TO DO: Add virtual user's initialization routines
lr.message("Initialize部分,我只执行一次哦!");
return lr.PASS;
}
// ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
public int Actions()
{
// TO DO: Add virtual user's business process actions
lr.message("Actions部分,我可以重复执行(在设置迭代情况下)!");
try
{
//设置连接字符串开始
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"Data Source=C:\\test.mdb";
//设置连接字符串结束
//插入一个集合点开始
lr.rendezvous("集合点");
//插入一个集合点结束
//事务开始
lr.start_transaction("SQL语句性能");
//建立OleDbConnection和OleDbCommand,并指定要运行的Sql语句开始
System.Data.OleDb.OleDbConnection conn=new
System.Data.OleDb.OleDbConnection(strConnection);
System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand();
cmd.Connection = conn;
cmd.CommandText = "select * from testdb";
//建立OleDbConnection和OleDbCommand,并指定要运行的Sql语句结束