0 Replies Latest reply on Jun 25, 2002 3:23 AM by ptheron

    Time to execute method in EJB

    ptheron

      Hi

      Below are two methods in a Remote SessionBean:

      from a servlet it takes:
      +/- 0.1 ms to call helloWorld()
      +/- 0.4 ms to call helloWorldWithLocal()

      from a java client it takes:
      +/- 3.0 ms to call helloWorld()
      +/- 6.0 ms to call helloWorldWithLocal()

      The time spend inside helloWorldWithLocal is +/- 0 ms - the question is: why is there such a big time delta between helloWorld() and helloWorldWithLocal()??

      public String helloWorldWithLocal () throws RemoteException {


      String localStr = "LOCAL BEAN NOT FOUND";
      long time1 =System.currentTimeMillis();

      try {
      LocalHelloHome hh = null;
      LocalHello hl = null;
      hh = (LocalHelloHome) (new InitialContext()).lookup("java:comp/env/ejb/LocalHelloBean");
      hl = hh.create();
      localStr = hl.helloWorld();
      } catch (Exception e) {
      localStr += ", " + e.toString();
      }

      long time2 =System.currentTimeMillis();
      localStr += "; Local time = " + (time2-time1) + " ms";

      return "Hello from myEjb.HelloBean" + localStr;
      }

      public String helloWorld () throws RemoteException {
      return "Hello from myEjb.HelloBean";
      }