做一个开发人员认可的测试人员(四)
作者:网络转载 发布时间:[ 2014/1/26 10:03:11 ] 推荐标签:响应时间 代码
//level load
long lvstart_Seq = (levelload_Start.getTime()-test_Start.getTime())/(driver_interval*1000) + 1;
long lvstop_Seq = 0;
if((levelload_End.getTime()-test_Start.getTime()) < driver_interval*1000)
{
lvstop_Seq = (levelload_End.getTime()-test_Start.getTime())/(driver_interval*1000) + 1;
}
else {
lvstop_Seq = (levelload_End.getTime()-test_Start.getTime())/(driver_interval*1000);
}
report.append("----> performance statistics for level load <----
");
report.append("----> level load started in interval " + lvstart_Seq
+ " , Date: " + df.format(levelload_Start) + " GMT <----
");
report.append("----> level load stopped in interval " + lvstop_Seq
+ " , Date: " + df.format(levelload_End) + " GMT <----
");
report
.append(" ========
#CaseName Description Loop_Cnt RspTime avgRspTimePerExe Err_Cnt Exe_Cnt
");
//merge
String condition="";
if(Config.getInstance().noReportForEmptyDes) {
condition = " and length(caseinfo.description)>0 ";
}
if (Config.getInstance().mergeResult)
{
sqlcmd = "select caseinfo.case_name,caseinfo.description, sum(l_cnt) lp_cnt," +
"sum(l_avg*l_cnt) total_resp, sum(err_cnt) , sum(exe_cnt) , sum(slp) from (" +
"select res.case_id, trunc(timestampdiff(2,char(res.ts - exec.ts_start))/exec.driver_interval, 0)+1 seq, sum(loop_count) l_cnt, " +
"avg(avg) l_avg, sum(error_count) err_cnt, sum(exe_count) exe_cnt, sum(total_sleeptime) slp " +
"from(select a.test_start +( (b.interval_seq-1)*a.driver_interval) seconds ts,b.case_id,b.interval_seq " +
"from execution a, tresult b where a.exec_id=b.exec_id and a.test_no="+test_no+" ) res," +
"(SELECT test_no, min(test_start) ts_start, max(test_end) ts_end, driver_interval FROM EXECUTION " +
"where test_no=" + test_no+" group by test_no,driver_interval) exec," +
"tresult where res.case_id = tresult.case_id and res.interval_seq=tresult.interval_seq " +
"group by res.case_id, trunc(timestampdiff(2,char(res.ts - exec.ts_start))/exec.driver_interval, 0)) result," +
"caseinfo where caseinfo.case_id=result.case_id and seq between " + lvstart_Seq +" and "+ lvstop_Seq+
condition +
" group by caseinfo.case_name,caseinfo.description";
}
else {
sqlcmd = "select caseinfo.case_name,caseinfo.description, sum(l_cnt) lp_cnt," +
"sum(l_avg*l_cnt) total_resp, sum(err_cnt) , sum(exe_cnt) , sum(slp), caseinfo.case_id from (" +
"select res.case_id, trunc(timestampdiff(2,char(res.ts - exec.ts_start))/exec.driver_interval, 0)+1 seq, sum(loop_count) l_cnt, " +
"avg(avg) l_avg, sum(error_count) err_cnt, sum(exe_count) exe_cnt, sum(total_sleeptime) slp " +
"from(select a.test_start +( (b.interval_seq-1)*a.driver_interval) seconds ts,b.case_id,b.interval_seq " +
"from execution a, tresult b where a.exec_id=b.exec_id and a.test_no="+test_no+" ) res," +
"(SELECT test_no, min(test_start) ts_start, max(test_end) ts_end, driver_interval FROM EXECUTION " +
"where test_no=" + test_no+" group by test_no,driver_interval) exec," +
"tresult where res.case_id = tresult.case_id and res.interval_seq=tresult.interval_seq " +
"group by res.case_id, trunc(timestampdiff(2,char(res.ts - exec.ts_start))/exec.driver_interval, 0)) result," +
"caseinfo where caseinfo.case_id=result.case_id and seq between " + lvstart_Seq +" and "+ lvstop_Seq+
condition +
" group by caseinfo.case_id,caseinfo.case_name,caseinfo.description";
}
//System.out.println(sqlcmd);
rs = ps.executeQuery(sqlcmd);
while(rs.next())
{
report.append(rs.getString(1)+","+rs.getString(2)+","+rs.getString(3)+","+
rs.getInt(4)/rs.getInt(3)+","+rs.getInt(4)/rs.getInt(6)+","+rs.getString(5)+","+
rs.getString(6)+"
");
}
} catch (Exception e) {
e.printStackTrace();
}
return report;
}
public static void storeResultfromFile(String fileName) throws IOException
{
FileReader fr = new FileReader(fileName); //perf.log
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
ArrayList dataList = new ArrayList();
boolean found = false;
while (line != null) {
if (line.indexOf("Final Report")<0 && (!found))
{
line = br.readLine();
continue;
}
else {
found = true;
}
dataList.add(line);
line = br.readLine();
}
//System.out.println(dataList);
String temp = new String();
//Get test start time
temp = dataList.get(3).toString();
String testStart_timestamp = temp.substring(20, 40);
//Get test stop time
temp = dataList.get(4).toString();
String testStop_timestamp = temp.substring(20, 40);
//VU
temp = dataList.get(5).toString();
int vu = Integer.parseInt(temp.substring(10, temp.lastIndexOf(" ")));
//Scenario name
temp = dataList.get(7).toString();
String sc_Name = temp.substring(15, temp.lastIndexOf(" "));
//testcase number
temp = dataList.get(8).toString();
int tc_num = Integer.parseInt(temp.substring(21, temp.lastIndexOf(" ")));
ArrayList testcases = new ArrayList();
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11