JAVA + LR???apache??y???????????LR?????
???????????? ???????[ 2012/11/20 15:04:10 ] ????????
???????LR??JAVA Vuser??????????????????JAVA????????????LR????????????????????????????????????????????κ??????????????????1??С??????LR???????ú???÷??????????????????????JAVA……?????????ɡ?
????Action.java???????£?
import lrapi.lr;
import com.test.*;
import java.util.*;
import java.io.*;
public class Actions
{
public int init() throws Throwable {
return 0;
}//end of init
public int action() throws Throwable {
/*
?????????
*/
int downloadSize = 0;
int downloadTime = 0;
long startTime = 0;
long endTime = 0;
int speed = 0;
int vid;
vid = lr.get_vuser_id();
/*
??url???????arraylist
*/
String url;
ArrayList urlList = new ArrayList();
try{
BufferedReader br = new BufferedReader(new FileReader("url.txt"));
??????????while((url = br.readLine()) != null){
???? urlList.add(url);
}
}catch(IOException ie){
????ie.printStackTrace();
}
lr.enable_redirection(true);
lr.set_debug_message(lr.MSG_CLASS_JIT_LOG_ON_ERROR?? lr.SWITCH_OFF);
System.out.println("Total URLs: " + urlList.size());
for(int i = 0; i < urlList.size(); i++){
????url = (String)urlList.get(i);
????System.out.println(url);
????//????????
????String trxName = "URL" + (i+1);
????startTime = System.currentTimeMillis();
????lr.start_transaction(trxName);
????//????url??????????????
????downloadSize = DownloadFile.getHttpFileByUrl(url?? Integer.toString(vid));
????lr.end_transaction(trxName?? lr.AUTO);
????endTime = System.currentTimeMillis();
????downloadTime = (int)(endTime - startTime)/1000;
????speed = downloadSize / downloadTime;
????lr.output_message(trxName + ": completed");
????lr.output_message("time cost: " + downloadTime + "s");
????lr.output_message("average speed: " + speed + "KB/s");
????lr.output_message("");
}
lr.set_debug_message(lr.MSG_CLASS_JIT_LOG_ON_ERROR?? lr.SWITCH_ON);
return 0;
}//end of action
public int end() throws Throwable {
return 0;
}//end of end
}
??????
???·???
??????????????????
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