用asp.net做个网站,怎么在本地进行压力测试,用什么工具
4个回答
展开全部
随机数,测试结果集合中根据获得的随机数获取测试结果
《《《《《~~~纯粹娱乐~~~》》》》》》
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<div style="text-align: center">
<h1>
趣味测试</h1>
</div>
<div style="text-align: center; width: 360px; border-style: dashed; border-width: 1px;">
<br />
<label>
请输入姓名:</label>
<asp:TextBox ID="txt_name" runat="server" MaxLength="4"></asp:TextBox><a style="margin-left: 20px"></a>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="测试" /><br />
<br />
<label>
测试结果:</label><asp:Label ID="lbl_jieguo" runat="server" Text="" Width="140px"></asp:Label><a
style="margin-left: 60px"></a><br />
<br />
</div>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = this.txt_name.Text;//姓名
CharEnumerator names= name.GetEnumerator();
int nameNo = 0;
while (names.MoveNext())
{//逐个字符
byte[] array = new byte[2];
if (ISChinese(names.Current.ToString()))
{
array = System.Text.Encoding.Default.GetBytes("" + names.Current.ToString().Trim() + "");
int front = (short)(array[0] - '\0');
int back = (short)(array[1] - '\0');
string nameNumber = Convert.ToString(front - 160) + Convert.ToString(back - 160);//取得区位码
nameNo = nameNo + Convert.ToInt32(nameNumber);//区位码相加
}
else
{
break;
}
}
if (nameNo == 0)
{ //如果有非汉字字符
ClientScript.RegisterClientScriptBlock(typeof(Page),"alert","alert('包含非汉字!')",true);
}
else
{
GetRandom(nameNo.ToString());
}
}
/// <summary>
/// 判断是否为汉字
/// </summary>
/// <param name="str_chinese"></param>
/// <returns></returns>
private bool ISChinese(string str_chinese)
{
return System.Text.RegularExpressions.Regex.IsMatch(str_chinese, @"^[\u4e00-\u9fa5],$");
}
/// <summary>
/// 获得结果
/// </summary>
/// <param name="nameNumber"></param>
private void GetRandom(string nameNumber)
{
string[] ceshiNeiRong = ; //保存测试结果的集合
int num = Convert.ToInt32(nameNumber);
int num2 = num % ceshiNeiRong.Length; //根据余数取集合中的数据
this.lbl_jieguo.Text = ceshiNeiRong[num2]; //页面赋值
}
}
《《《《《~~~纯粹娱乐~~~》》》》》》
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div style="text-align: center">
<div style="text-align: center">
<h1>
趣味测试</h1>
</div>
<div style="text-align: center; width: 360px; border-style: dashed; border-width: 1px;">
<br />
<label>
请输入姓名:</label>
<asp:TextBox ID="txt_name" runat="server" MaxLength="4"></asp:TextBox><a style="margin-left: 20px"></a>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="测试" /><br />
<br />
<label>
测试结果:</label><asp:Label ID="lbl_jieguo" runat="server" Text="" Width="140px"></asp:Label><a
style="margin-left: 60px"></a><br />
<br />
</div>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string name = this.txt_name.Text;//姓名
CharEnumerator names= name.GetEnumerator();
int nameNo = 0;
while (names.MoveNext())
{//逐个字符
byte[] array = new byte[2];
if (ISChinese(names.Current.ToString()))
{
array = System.Text.Encoding.Default.GetBytes("" + names.Current.ToString().Trim() + "");
int front = (short)(array[0] - '\0');
int back = (short)(array[1] - '\0');
string nameNumber = Convert.ToString(front - 160) + Convert.ToString(back - 160);//取得区位码
nameNo = nameNo + Convert.ToInt32(nameNumber);//区位码相加
}
else
{
break;
}
}
if (nameNo == 0)
{ //如果有非汉字字符
ClientScript.RegisterClientScriptBlock(typeof(Page),"alert","alert('包含非汉字!')",true);
}
else
{
GetRandom(nameNo.ToString());
}
}
/// <summary>
/// 判断是否为汉字
/// </summary>
/// <param name="str_chinese"></param>
/// <returns></returns>
private bool ISChinese(string str_chinese)
{
return System.Text.RegularExpressions.Regex.IsMatch(str_chinese, @"^[\u4e00-\u9fa5],$");
}
/// <summary>
/// 获得结果
/// </summary>
/// <param name="nameNumber"></param>
private void GetRandom(string nameNumber)
{
string[] ceshiNeiRong = ; //保存测试结果的集合
int num = Convert.ToInt32(nameNumber);
int num2 = num % ceshiNeiRong.Length; //根据余数取集合中的数据
this.lbl_jieguo.Text = ceshiNeiRong[num2]; //页面赋值
}
}
展开全部
vs2008 里面,新建测试项目,压力测试。自己试下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
百度一下 LoadRunner 你就知道。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
什么压力啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询