/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. package kilim.bench.rmi;
  7. import java.rmi.*;
  8. import java.rmi.server.UnicastRemoteObject;
  9. import java.util.Hashtable;
  10. import kilim.Task;
  11. public class RMI {
  12. public static void main(String[] args) throws Exception {
  13. int ntimes = args.length == 0 ? 1000 : Integer.parseInt(args[0]);
  14. Server obj = new Server();
  15. Ping stub = (Ping) UnicastRemoteObject.exportObject(obj, 0);
  16. Hashtable<String, String> h = new Hashtable<String, String>();
  17. h.put("foo", "bar");
  18. h.put("hello", "world");
  19. long begin = System.currentTimeMillis();
  20. for (int i = 0; i < ntimes; i++) {
  21. // System.out.println("Sending hash " + System.identityHashCode(h));
  22. stub.ping(i);
  23. }
  24. System.out.println("Elapsed (" + ntimes + " iters) : " +
  25. (System.currentTimeMillis() - begin) + " millis");
  26. UnicastRemoteObject.unexportObject(obj,false);
  27. }
  28. }
  29. interface Ping extends Remote {
  30. // void ping(Hashtable<String, String> h) throws RemoteException;
  31. void ping(int i) throws RemoteException;
  32. }
  33. class Server implements Ping {
  34. public void ping(int i) throws RemoteException {
  35. // System.out.println(i);
  36. }
  37. }