package edu.vt.marian.server; import java.io.*; import java.lang.*; import java.util.*; import edu.vt.marian.common.*; //============================================================================== // class name: test_statistics // class description: used to caculate the request, time for the performance // testing of the system // author: Jianxin Zhao // date; 05/06/99 //============================================================================== public class test_statistics extends Thread { // this vector contains time to process and complexity // of all the type 1 requests, type 1 means those reached the back end server private Vector type_1_request_process_times = new Vector(); // this vector contains the time to process values for all the type 2 requests // type 2 means those didn't reach the back end server private Vector type_2_request_process_times = new Vector(); // these two vectors record the srart and end process times for all the // type 1 requests along with their request id, used by java server private Vector type_1_request_process_start_times = new Vector(); private Vector type_1_request_process_end_times = new Vector(); // these two vectors record the srart and end process times for all the // type 1 requests along with their request id, used by webgate // to deal with search_collection and biblio_query_text private Vector type_1_request_process_start_times_1 = new Vector(); private Vector type_1_request_process_end_times_1 = new Vector(); private Vector type_1_request_process_start_times_2 = new Vector(); private Vector type_1_request_process_end_times_2 = new Vector(); // this value specifies the up limit of request process time // time longer than this will be regarded as a bad request private final long request_process_time_upper_limit = 60000; // those variabl records the number of bad requests of each type so far private int type_1_bad_request_number = 0; private int type_2_bad_request_number = 0; // these value records the start and end time of the statistics private long start_time = 0; private long end_time = 0; // those variables are used to print out temporary results from time to time private long last_type_1_request_number = 0; private long last_type_2_request_number = 0; private long last_check_time = 0; private PrintWriter temp_pw = null; private long dump_results_interval = 20000; // this constructor will create a test_statistics object and start tpo run it // so that it will print out results from time to time public test_statistics(String file_name, boolean append) { try { temp_pw = new PrintWriter(new FileWriter(file_name, append)); } catch (Exception e) { System.err.println("class test_statistics, constructor, error open temporary file to wriyte"); } this.start(); } // this method will dump the final results to the file spefcified in the parameter public void dump_final_results(String file_name, boolean append) { this.stop(); temp_pw.close(); // open the file PrintWriter pw = null; try { pw = new PrintWriter(new FileWriter(file_name, append)); } catch (Exception e) { System.err.println("class test_statistics, method dump_final_results, error open file to write"); } int i, j; if (type_1_request_process_times.size() != 0) { // this object is used by the test program // this is used to do the time statistics based on query complexity // assuming the weight value is less than 57 long[][] comp_time = new long[57][2]; // initialize them for (i = 0; i < 57; i++) { comp_time[i][0] = 0; comp_time[i][1] = 0; } // dump overall statistics first long total_time = (end_time - start_time) / 1000; if (total_time == 0) { System.err.println("class test_statistics, method dump final results, total_time is 0"); return; } long total_requests = type_1_request_process_times.size() + type_2_request_process_times.size() + type_1_bad_request_number + type_2_bad_request_number; pw.println("The testing has been run " + total_time + " seconds."); pw.println("Good type 1 requests " + type_1_request_process_times.size()); pw.println("Bad type 1 requests " + type_1_bad_request_number); pw.println("Good type 2 requests " + type_2_request_process_times.size()); pw.println("Bad type 2 requests " + type_2_bad_request_number); pw.println("Total requests " + total_requests); pw.println("Type 1 request frequency (#/min)" + (type_1_request_process_times.size() + type_1_bad_request_number) * 60 / total_time); long total_process_time = 0; Vector element = null; int complexity = 0; long time = 0; for (i = 0; i < type_1_request_process_times.size(); i++) { element = (Vector) type_1_request_process_times.elementAt(i); complexity = ((Integer) element.elementAt(0)).intValue(); time = ((Long) element.elementAt(1)).longValue(); if (complexity > 56) { System.err.println("class test_statistics, method dump_final_results, invalid complexity" + complexity); return; } comp_time[complexity][0]++; comp_time[complexity][1] += time; total_process_time += time; } long average = total_process_time / i; pw.println("Request type 1 average response time(ms): " + average); // caculate the dv for it long process_time_dv = 0; for (i = 0; i < type_1_request_process_times.size(); i++) { element = (Vector) type_1_request_process_times.elementAt(i); time = ((Long) element.elementAt(1)).longValue(); process_time_dv += Math.abs(time - average) * Math.abs(time - average); } process_time_dv /= i; pw.println("Request type 1 standard diavation: " + Math.sqrt(process_time_dv)); // process request type 2 total_requests = type_2_request_process_times.size(); total_process_time = 0; for (i = 0; i < type_2_request_process_times.size(); i++) { total_process_time += ((Long) type_2_request_process_times.elementAt(i)).longValue(); } average = total_process_time / i; pw.println("Request type 2 average response time(ms): " + average); // caculate the dv for it process_time_dv = 0; for (i = 0; i < type_2_request_process_times.size(); i++) { time = ((Long) type_2_request_process_times.elementAt(i)).longValue(); process_time_dv += Math.abs(time - average) * Math.abs(time - average); } process_time_dv /= i; pw.println("Request type 2 standard diavation: " + Math.sqrt(process_time_dv)); // dump complexity statistics to the file pw.println(""); pw.println("Complexity Counts Average response time(ms)"); pw.println("==========================================================="); for (i = 0; i < comp_time.length; i++) { if (comp_time[i][0] != 0) { // at least there is one query of this complexity pw.println(i + " " + comp_time[i][0] + " " + comp_time[i][1] / comp_time[i][0]); } } // dump detailed data for request type 1 pw.println(""); pw.println("Request type 1 detailed data:"); pw.println("No Complexity Response Time(ms)"); pw.println("========================================="); for (i = 0; i < type_1_request_process_times.size(); i++) { element = (Vector) type_1_request_process_times.elementAt(i); pw.println(i + " " + ((Integer) element.elementAt(0)).intValue() + " " + ((Long) element.elementAt(1)).longValue()); } // dump detailed data for request type 2 pw.println(""); pw.println("Request type 2 detailed data:"); pw.println("No Response Time"); pw.println("======================"); for (i = 0; i < type_2_request_process_times.size(); i++) { pw.println(i + " " + ((Long) type_2_request_process_times.elementAt(i)).longValue()); } // flush and close the file at last pw.flush(); pw.close(); return; } // end -- if (type_1_request_process_times.size() != 0) // this test program is used by either webgate or the back end server if (type_1_request_process_start_times.size() != 0) { // this object is used by java server // dump general statistics first Vector element = (Vector) type_1_request_process_start_times.firstElement(); start_time = ((Long) element.elementAt(1)).longValue(); if (type_1_request_process_end_times.size() == 0) { System.err.println("class test_statistics, method dump_final_results, time vector size 0"); return; } element = (Vector) type_1_request_process_end_times.elementAt( type_1_request_process_end_times.size() - 1); end_time = ((Long) element.elementAt(1)).longValue(); element = (Vector) type_1_request_process_start_times.elementAt( type_1_request_process_start_times.size() - 1); if (end_time < ((Long) element.elementAt(1)).longValue()) { // this is the real test end time end_time = ((Long) element.elementAt(1)).longValue(); } long total_time = (end_time - start_time) / 1000; long total_requests = type_1_request_process_start_times.size(); pw.println("The test has been run " + total_time + " seconds"); pw.println("Total type 1 requests " + total_requests); pw.println("Total type 2 requests 0"); pw.println("Request requency (#/min) " + total_requests * 60 / total_time ); long total_process_time = 0; Vector element_1 = null; int start_id = 0; int end_id = 0; long process_start_time = 0; long process_end_time = 0; boolean find = false; for (i = 0; i < type_1_request_process_start_times.size(); i++) { find = false; element = (Vector) type_1_request_process_start_times.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); for (j = 0; j < type_1_request_process_end_times.size(); j++) { element_1 = (Vector) type_1_request_process_end_times.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element.elementAt(1)).longValue(); process_end_time = ((Long) element_1.elementAt(1)).longValue(); if ((process_end_time - process_start_time) >= request_process_time_upper_limit) { // this request take system too long time to process // count it as a bad one type_1_bad_request_number++; } else { total_process_time += process_end_time - process_start_time; } find = true; break; } } // end -- for (j ...) if (! find) { // this request is not accomplished by the system, count it // as a bad request type_1_bad_request_number++; } } // end -- for (i ...) long average = total_process_time / (type_1_request_process_start_times.size() - type_1_bad_request_number); pw.println("Type 1 bad request number " + type_1_bad_request_number); pw.println("Request type 1 average response time(ms) " + average); // caculate the standard dv long process_time_dv = 0; for (i = 0; i < type_1_request_process_start_times.size(); i++) { element = (Vector) type_1_request_process_start_times.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); for (j = 0; j < type_1_request_process_end_times.size(); j++) { element_1 = (Vector) type_1_request_process_end_times.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element.elementAt(1)).longValue(); process_end_time = ((Long) element_1.elementAt(1)).longValue(); if ((process_end_time - process_start_time) < request_process_time_upper_limit) { process_time_dv += Math.abs(process_end_time - process_start_time - average) * Math.abs(process_end_time - process_start_time - average); } break; } } // end -- for (j ...) } // end -- for (i ...) process_time_dv /= (type_1_request_process_start_times.size() - type_1_bad_request_number); pw.println("Request type 1 response time standard diaviation " + Math.sqrt(process_time_dv)); // dump detailed data pw.println(""); pw.println("Detailed data"); pw.println("request no request id process time(ms) bad request?"); pw.println("=============================================================="); for (i = 0; i < type_1_request_process_start_times.size(); i++) { find = false; element = (Vector) type_1_request_process_start_times.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); for (j = 0; j < type_1_request_process_end_times.size(); j++) { element_1 = (Vector) type_1_request_process_end_times.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element.elementAt(1)).longValue(); process_end_time = ((Long) element_1.elementAt(1)).longValue(); if ((process_end_time - process_start_time) >= request_process_time_upper_limit) { pw.println(i + " " + start_id + " " + (process_end_time - process_start_time) + " yes"); } else { pw.println(i + " " + start_id + " " + (process_end_time - process_start_time)); } find = true; break; } } // end -- for (j ...) if (! find) { // this request is not accomplished by the system, count it // as a bad request pw.println(i + " " + start_id + " not finished yes"); } } // end -- for (i ...) // flush and close the file at last pw.flush(); pw.close(); return; } // end -- if (type_1_request_process_start_times.size() != 0) // this object is used by webgate // dump general statistics first if (type_1_request_process_start_times_1.size() == 0) { System.err.println("class test_statistics, method dump_final_results, time vector size 0"); return; } Vector element = (Vector) type_1_request_process_start_times_1.firstElement(); start_time = ((Long) element.elementAt(1)).longValue(); if (type_1_request_process_end_times_2.size() == 0) { System.err.println("class test_statistics, method dump_final_results, time vector size 0"); return; } element = (Vector) type_1_request_process_end_times_2.elementAt( type_1_request_process_end_times_2.size() - 1); end_time = ((Long) element.elementAt(1)).longValue(); element = (Vector) type_1_request_process_start_times_1.elementAt( type_1_request_process_start_times_1.size() - 1); if (end_time < ((Long) element.elementAt(1)).longValue()) { // this is the real test end time end_time = ((Long) element.elementAt(1)).longValue(); } long total_time = (end_time - start_time) / 1000; long total_requests = type_1_request_process_start_times_1.size(); pw.println("The test has been run " + total_time + " seconds"); pw.println("Total type 1 requests " + total_requests); pw.println("Total type 2 requests 0"); pw.println("Request requency (#/min) " + total_requests * 60 / total_time ); long total_process_time = 0; long process_time = 0; Vector element_1 = null; int start_id = 0; int end_id = 0; long process_start_time = 0; long process_end_time = 0; boolean find = false; for (i = 0; i < type_1_request_process_start_times_1.size(); i++) { find = false; element = (Vector) type_1_request_process_start_times_1.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); // try to find the first process time for (j = 0; j < type_1_request_process_end_times_1.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_1.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element.elementAt(1)).longValue(); process_end_time = ((Long) element_1.elementAt(1)).longValue(); process_time = process_end_time - process_start_time; find = true; break; } } // end -- for (j ...) if (! find) { // this request is not accomplished by the system, count it // as a bad request type_1_bad_request_number++; continue; } // this request passes first process, try to find the second process time find = false; for (j = 0; j < type_1_request_process_start_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_start_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element_1.elementAt(1)).longValue(); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one type_1_bad_request_number++; continue; } // the second start process time has been found, try to find it's end time find = false; for (j = 0; j < type_1_request_process_end_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_end_time = ((Long) element_1.elementAt(1)).longValue(); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one type_1_bad_request_number++; continue; } // the second end time has been find too, process this request time process_time += (process_end_time - process_start_time); if (process_time >= request_process_time_upper_limit) { // this request took too long to process, count it as a bad one type_1_bad_request_number++; continue; } // this is a normal request, put its value to statistics total_process_time += process_time; } // end -- for (i = 0; i < type_1_request_process_start_times_1.size(); i++) long average = total_process_time / (type_1_request_process_start_times_1.size() - type_1_bad_request_number); pw.println("Type 1 bad request number " + type_1_bad_request_number); pw.println("Request type 1 average response time(ms) " + average); // caculate the standard dv long process_time_dv = 0; for (i = 0; i < type_1_request_process_start_times_1.size(); i++) { find = false; element = (Vector) type_1_request_process_start_times_1.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); // try to find the first process time for (j = 0; j < type_1_request_process_end_times_1.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_1.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element.elementAt(1)).longValue(); process_end_time = ((Long) element_1.elementAt(1)).longValue(); process_time = process_end_time - process_start_time; find = true; break; } } // end -- for (j ...) if (! find) { // this request is not accomplished by the system, count it // as a bad request continue; } // this request passes fir process, try to find the second process time find = false; for (j = 0; j < type_1_request_process_start_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_start_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element_1.elementAt(1)).longValue(); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one continue; } // the second start process time has been found, try to find it's end time find = false; for (j = 0; j < type_1_request_process_end_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_end_time = ((Long) element_1.elementAt(1)).longValue(); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one continue; } // the second end time has been find too, process this request time process_time += (process_end_time - process_start_time); if (process_time >= request_process_time_upper_limit) { // this request took too long to process, count it as a bad one continue; } // this is a notmal request, put its value to statistics process_time_dv += Math.abs(process_time - average) * Math.abs(process_time - average); } // end -- for (i = 0; i < type_1_request_process_start_times_1.size(); i++) process_time_dv /= (type_1_request_process_start_times_1.size() - type_1_bad_request_number); pw.println("Request type 1 response time standard diaviation " + Math.sqrt(process_time_dv)); // dump detailed data pw.println(""); pw.println("Detailed data"); pw.println("no id time1(ms) time2(ms) total_time(ms) bad request?"); pw.println("=============================================================="); for (i = 0; i < type_1_request_process_start_times_1.size(); i++) { // print the request no pw.print(i); element = (Vector) type_1_request_process_start_times_1.elementAt(i); start_id = ((Integer) element.elementAt(0)).intValue(); // print the request id pw.print(" " + start_id); // print start time 1 process_start_time = ((Long) element.elementAt(1)).longValue(); // try to find the first process time find = false; for (j = 0; j < type_1_request_process_end_times_1.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_1.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_end_time = ((Long) element_1.elementAt(1)).longValue(); // print the end time 1 pw.print(" " + (process_end_time - process_start_time)); process_time = process_end_time - process_start_time; find = true; break; } } // end -- for (j ...) if (! find) { // this request is not accomplished by the system, count it // as a bad request pw.println(" N/A N/A N/A yes"); continue; } // this request passes fir process, try to find the second process time find = false; for (j = 0; j < type_1_request_process_start_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_start_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_start_time = ((Long) element_1.elementAt(1)).longValue(); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one pw.println(" N/A N/A yes"); continue; } // the second start process time has been found, try to find it's end time find = false; for (j = 0; j < type_1_request_process_end_times_2.size(); j++) { element_1 = (Vector) type_1_request_process_end_times_2.elementAt(j); end_id = ((Integer) element_1.elementAt(0)).intValue(); if (start_id == end_id) { // this request has been accomplished by the system process_end_time = ((Long) element_1.elementAt(1)).longValue(); // print the end time 2 pw.print(" " + (process_end_time - process_start_time)); find = true; break; } } // end -- for (j ...) if (! find) { // this request has not been finished by the system, count it // as a bad one pw.println(" N/A N/A yes"); continue; } // the second end time has been find too, process this request time process_time += (process_end_time - process_start_time); if (process_time >= request_process_time_upper_limit) { // this request took too long to process, count it as a bad one pw.println(" " + process_time + " yes"); continue; } // this is a notmal request pw.println(" " + process_time); } // end -- for (i = 0; i < type_1_request_process_start_times_1.size(); i++) // flush and close the file at last pw.flush(); pw.close(); return; } // this method will record the new request to this object public void record_request_process_time(int request_type, long process_time, int complexity) { // first record start and end time if necessary long current_time = (new Date()).getTime(); if (start_time == 0) { start_time = current_time; } end_time = current_time; // record the processing time for the request if (request_type == 1) { // this is a request reached the back-end server Vector element = new Vector(2); element.addElement(new Integer(complexity)); element.addElement(new Long(process_time)); type_1_request_process_times.addElement(element); return; } // this is a which only reached the webgate type_2_request_process_times.addElement(new Long(process_time)); return; } // this method will record that a bad type 1 request happened public synchronized void record_type_1_bad_request() { type_1_bad_request_number++; return; } // this method will record that a bad type 2 request happened public synchronized void record_type_2_bad_request() { type_2_bad_request_number++; return; } // this method will report to this object that a request // with the specified id has been sent to the system to process public void record_request_begin(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_start_times.addElement(element); return; } // this method will report to this object that a request // with the specified id has been processes by the system public void record_request_end(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_end_times.addElement(element); return; } // this method will report to this object that a request // with the specified id has been sent to the system to process public void record_request_begin_1(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_start_times_1.addElement(element); return; } // this method will report to this object that a request // with the specified id has been processes by the system public void record_request_end_1(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_end_times_1.addElement(element); return; } // this method will report to this object that a request // with the specified id has been sent to the system to process public void record_request_begin_2(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_start_times_2.addElement(element); return; } // this method will report to this object that a request // with the specified id has been processes by the system public void record_request_end_2(int request_id) { Date d = new Date(); Vector element = new Vector(2); element.addElement(new Integer(request_id)); element.addElement(new Long(d.getTime())); type_1_request_process_end_times_2.addElement(element); return; } // this method will dump temporary results to the temporary file public void dump_temporary_results() { temp_pw.println("=========================================="); Date d = new Date(); temp_pw.println(d.toString()); if (last_check_time == 0) { // this is the first time this method is called last_check_time = d.getTime(); temp_pw.println("start checking"); return; } // this is not the first time, dump some temporary results if (type_1_request_process_times.size() != 0) { // this object is used by the test program long type_1_request_number = type_1_request_process_times.size(); long type_2_request_number = type_2_request_process_times.size(); temp_pw.println("Total type 1 requests " + type_1_request_number); temp_pw.println("Total type 2 requests " + type_2_request_number); temp_pw.println("Bad type 1 request number " + type_1_bad_request_number); temp_pw.println("Bad type 2 request number " + type_2_bad_request_number); // caculate the average response time Vector element = null; long total_process_time = 0; for (long i = last_type_1_request_number; i < type_1_request_number; i++) { element = (Vector) type_1_request_process_times.elementAt((int) i); total_process_time += ((Long) element.elementAt(1)).longValue(); } if (total_process_time != 0) { temp_pw.println("Type 1 request average process time(ms) " + total_process_time / (type_1_request_number - last_type_1_request_number)); } else { temp_pw.println("Type 1 request 0"); } total_process_time = 0; for (long i = last_type_2_request_number; i < type_2_request_number; i++) { total_process_time += ((Long) type_2_request_process_times.elementAt((int) i)).longValue(); } if (total_process_time != 0) { temp_pw.println("Type 2 request average process time(ms) " + total_process_time / (type_2_request_number - last_type_2_request_number)); } else { temp_pw.println("Type 2 request 0"); } // caculate request frequency long time_duration = (d.getTime() - last_check_time) / 1000; long frequency = (type_1_request_number - last_type_1_request_number) * 60 / time_duration; temp_pw.println("Type 1 request frequency(#/min) " + frequency); frequency = (type_2_request_number - last_type_2_request_number) * 60 / time_duration; temp_pw.println("Type 2 request frequency(#/min) " + frequency); // at last prepare for the next time last_type_1_request_number = type_1_request_number; last_type_2_request_number = type_2_request_number; last_check_time = d.getTime(); // flush the file at last temp_pw.flush(); return; } else if (type_1_request_process_start_times.size() != 0) { // this object is used by Java server // only request number and frequency is available in this case long type_1_request_number = type_1_request_process_start_times.size(); temp_pw.println("Total type 1 requests so far " + type_1_request_number); // frequency long time_duration = (d.getTime() - last_check_time) / 1000; long frequency = (type_1_request_number - last_type_1_request_number) * 60 / time_duration; temp_pw.println("Type 1 request frequency(#/min) " + frequency); // at last prepare for the next time last_check_time = d.getTime(); last_type_1_request_number = type_1_request_number; // flush the file at last temp_pw.flush(); return; } else if (type_1_request_process_start_times_1.size() != 0) { // this object is used by webgate // only request number and frequency is available in this case long type_1_request_number = type_1_request_process_start_times_1.size(); temp_pw.println("Total type 1 requests so far " + type_1_request_number); // frequency long time_duration = (d.getTime() - last_check_time) / 1000; long frequency = (type_1_request_number - last_type_1_request_number) * 60 / time_duration; temp_pw.println("Type 1 request frequency(#/min) " + frequency); // at last prepare for the next time last_check_time = d.getTime(); last_type_1_request_number = type_1_request_number; // flush the file at last temp_pw.flush(); return; } // no results available yet temp_pw.println("no results available yet"); temp_pw.flush(); return; } // this method will dump the temporary results to the temporary file // from time to time public void run() { while (true) { dump_temporary_results(); try { sleep(dump_results_interval); } catch (Exception e) { System.err.println("class test_statistics, method run, error happend in sleeping"); } } } }