~andre-dau/jhelioviewer/welcome

« back to all changes in this revision

Viewing changes to vso/src/org/helioviewer/vso/Benchmark.java

  • Committer: Helge Dietert
  • Date: 2010-07-21 18:26:09 UTC
  • mfrom: (189.1.11 vsoIntegrated)
  • Revision ID: helge@clem.local-20100721182609-qfmi23gqm0wkmm7n
Integrated VSO Client

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.helioviewer.vso;
 
2
 
 
3
import java.io.File;
 
4
import java.io.FileOutputStream;
 
5
import java.io.IOException;
 
6
import java.io.OutputStreamWriter;
 
7
 
 
8
import javax.xml.rpc.ServiceException;
 
9
 
 
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;
 
17
 
 
18
public class Benchmark {
 
19
 
 
20
    /**
 
21
     * Simple benchmarking the query time It requests the data, parse them and
 
22
     * need to print it to the file performanceTest-temp.txt
 
23
     * 
 
24
     * We request between 20040101000000 - 20040103000000, five times. The time
 
25
     * initializing is not counted.
 
26
     * 
 
27
     * @param args
 
28
     * @throws ServiceException
 
29
     * @throws IOException
 
30
     */
 
31
    public static void main(String[] args) throws ServiceException, IOException {
 
32
        // Set up
 
33
        PropertyConfigurator.configure("BenchmarkLog4j.properties");
 
34
        // Get stub connection
 
35
        VSOiServiceLocator vsoLoc = new VSOiServiceLocator();
 
36
        VSOiPort port = vsoLoc.getsdacVSOi();
 
37
        // Get output file
 
38
        OutputStreamWriter testOut = new OutputStreamWriter(new FileOutputStream(new File("performanceTest-temp.txt")));
 
39
        // Start timing
 
40
        long start = System.currentTimeMillis();
 
41
        for (int i = 0; i < 3; ++i) {
 
42
            // Building request
 
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");
 
48
            block.setTime(qTime);
 
49
            req.setBlock(block);
 
50
            // Send request
 
51
            ProviderQueryResponse[] res = port.query(req);
 
52
            // Print result
 
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");
 
65
                    }
 
66
                }
 
67
                testOut.write("\n\n");
 
68
            }
 
69
        }
 
70
        // Stop timer
 
71
        long end = System.currentTimeMillis();
 
72
        System.out.println("Needed time: " + (end - start));
 
73
    }
 
74
}