PageRenderTime 15ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/bench/kilim/bench/rmi/RMI.java

http://github.com/kilim/kilim
Java | 42 lines | 29 code | 5 blank | 8 comment | 2 complexity | 6236985954e69aa651bcc054874d2755 MD5 | raw file
 1/* Copyright (c) 2006, Sriram Srinivasan
 2 *
 3 * You may distribute this software under the terms of the license 
 4 * specified in the file "License"
 5 */
 6
 7package kilim.bench.rmi;
 8import java.rmi.*;
 9import java.rmi.server.UnicastRemoteObject;
10import java.util.Hashtable;
11import kilim.Task;
12public class RMI {
13    public static void main(String[] args) throws Exception {
14        int ntimes = args.length == 0 ? 1000 : Integer.parseInt(args[0]);
15        Server obj = new Server();
16        Ping stub = (Ping) UnicastRemoteObject.exportObject(obj, 0);
17        Hashtable<String, String> h = new Hashtable<String, String>();
18        h.put("foo", "bar");
19        h.put("hello", "world");
20        long begin = System.currentTimeMillis();
21        for (int i = 0; i < ntimes; i++) {
22//            System.out.println("Sending hash " + System.identityHashCode(h));
23            stub.ping(i);
24        }
25        System.out.println("Elapsed (" + ntimes + " iters) : " + 
26                (System.currentTimeMillis() - begin) + " millis");
27        UnicastRemoteObject.unexportObject(obj,false);
28    }
29}
30
31interface Ping extends Remote {
32//    void ping(Hashtable<String, String> h) throws RemoteException;
33  void ping(int i) throws RemoteException;
34}
35
36class Server implements Ping {
37    public void ping(int i) throws RemoteException {
38//        System.out.println(i);
39    }
40    
41}
42