@Override
    public void receive(Object msg, ActorRef sender) throws Exception {
      if (msg instanceof Init) {
        Init init = (Init) msg;
        self = init.container;
      } else if (msg instanceof Run) {
        System.out.println("Run encountered");
        Run run = (Run) msg;
        latch = run.countDownLatch;
        repeat = run.repeat;
        int count = run.repeat;
        target = run.target;
        for (int k = 0; k < Math.min(1000, count); k++) {
          target.post(null, self);
          sent += 1;
        }
      } else {
        received += 1;
        if (sent < repeat) {
          target.post(null, self);
          sent += 1;
        } else if (received >= repeat) {
          latch.countDown();
          target.post(null, new Info());
        }

        if (sent % 1000000 == 0) {
          System.out.println("Client at: " + sent);
        }
      }
    }
 @Override
 public void receive(Object msg, ActorRef sender) throws Exception {
   if (msg instanceof Init) {
     self = ((Init) msg).container;
   } else if (msg instanceof Info) {
     // System.out.println("count:" + count + " destination:" + toString());
   } else {
     count++;
     ActorContainer s = (ActorContainer) msg;
     s.post(null, self);
   }
 }
  public void test(int numberOfClients, ActorContainerFactory containerFactory)
      throws InterruptedException {
    int messageCount = 100 * 1000 * 1000;
    long totalMessageCount = numberOfClients * messageCount;

    ActorContainer[] destinations = new ActorContainer[numberOfClients];
    ActorRecipe<Destination> destinationRecipe = new ActorRecipe<>(Destination.class, 0);
    for (int k = 0; k < destinations.length; k++) {
      ActorRef ref = TestUtils.newRandomActorRef();
      ActorContainer container = containerFactory.newContainer(destinationRecipe, ref, monitorMap);
      container.activate(actorRuntime, nodeService, actorFactory);
      container.post(null, new Init(container));
      destinations[k] = container;
    }

    ActorContainer[] clients = new ActorContainer[numberOfClients];
    ActorRecipe<Client> clientRecipe = new ActorRecipe<>(Client.class, 0);
    for (int k = 0; k < clients.length; k++) {
      ActorRef ref = TestUtils.newRandomActorRef();
      ActorContainer container = containerFactory.newContainer(clientRecipe, ref, monitorMap);
      container.activate(actorRuntime, nodeService, actorFactory);
      container.post(null, new Init(container));
      clients[k] = container;
    }

    CountDownLatch latch = new CountDownLatch(numberOfClients);

    System.out.println("Starting Benchmark");
    long startTimeMs = System.currentTimeMillis();

    for (int k = 0; k < numberOfClients; k++) {
      ActorContainer client = clients[k];
      ActorContainer destination = destinations[k];
      client.post(null, new Run(destination, messageCount, latch));
    }

    latch.await();

    long durationMs = System.currentTimeMillis() - startTimeMs;
    System.out.println("Completed Benchmark");
    System.out.println("Total number of messages send: " + totalMessageCount);
    System.out.println("Total duration: " + durationMs + " ms");
    double performance = (1000d * totalMessageCount) / durationMs;
    System.out.println("Performance:" + String.format("%1$,.2f", performance) + " messages/second");
  }