1
package org.helioviewer.vso;
4
import java.io.FileOutputStream;
5
import java.io.IOException;
6
import java.io.OutputStreamWriter;
8
import javax.xml.rpc.ServiceException;
10
import org.apache.log4j.PropertyConfigurator;
11
import org.virtualsolar.VSO.VSOi.ProviderQueryResponse;
12
import org.virtualsolar.VSO.VSOi.QueryRequest;
13
import org.virtualsolar.VSO.VSOi.QueryRequestBlock;
14
import org.virtualsolar.VSO.VSOi.QueryResponseBlock;
15
import org.virtualsolar.VSO.VSOi.VSOiPort;
16
import org.virtualsolar.VSO.VSOi.VSOiServiceLocator;
18
public class Benchmark {
21
* Simple benchmarking the query time It requests the data, parse them and
22
* need to print it to the file performanceTest-temp.txt
24
* We request between 20040101000000 - 20040103000000, five times. The time
25
* initializing is not counted.
28
* @throws ServiceException
31
public static void main(String[] args) throws ServiceException, IOException {
33
PropertyConfigurator.configure("BenchmarkLog4j.properties");
34
// Get stub connection
35
VSOiServiceLocator vsoLoc = new VSOiServiceLocator();
36
VSOiPort port = vsoLoc.getsdacVSOi();
38
OutputStreamWriter testOut = new OutputStreamWriter(new FileOutputStream(new File("performanceTest-temp.txt")));
40
long start = System.currentTimeMillis();
41
for (int i = 0; i < 3; ++i) {
43
QueryRequest req = new QueryRequest();
44
QueryRequestBlock block = new QueryRequestBlock();
45
org.virtualsolar.VSO.VSOi.Time qTime = new org.virtualsolar.VSO.VSOi.Time();
46
qTime.setStart("20040101000000");
47
qTime.setEnd("20040103000000");
51
ProviderQueryResponse[] res = port.query(req);
53
for (ProviderQueryResponse r : res) {
54
testOut.write("Provider:" + r.getProvider() + "\n");
55
if (r.getRecord() != null) {
56
for (QueryResponseBlock b : r.getRecord()) {
57
testOut.write("\t---");
58
testOut.write("\tProvider: " + b.getProvider() + "\n");
59
testOut.write("\tInfo: " + b.getInfo() + "\n");
60
testOut.write("\tSource: " + b.getSource() + "\n");
61
testOut.write("\tPptid: " + b.getPptid() + "\n");
62
testOut.write("\tInstrument: " + b.getInstrument() + "\n");
63
testOut.write("\tPhysobs: " + b.getPhysobs() + "\n");
64
testOut.write("\tFileId: " + b.getFileid() + "\n");
67
testOut.write("\n\n");
71
long end = System.currentTimeMillis();
72
System.out.println("Needed time: " + (end - start));