???????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
 }