public static void main(String[] args) throws Exception {
    int port = -1;
    int iterations = -1;
    int wait = 0;

    for (int i = 0; i < args.length; i++) {
      if (args[i].equals("-wait")) {
        if (++i >= args.length) {
          usage("Missing wait time");

        } else {
          try {
            wait = Integer.parseInt(args[i]);

          } catch (NumberFormatException ex) {
            usage("Malformed wait time: " + args[i]);
          }
        }

      } else if (port == -1) {
        try {
          port = Integer.parseInt(args[i]);

        } catch (NumberFormatException ex) {
          usage("Malformed port: " + args[i]);
        }

      } else if (iterations == -1) {
        try {
          iterations = Integer.parseInt(args[i]);

        } catch (NumberFormatException ex) {
          usage("Malformed iterations: " + args[i]);
        }

      } else {
        usage("Extraneous command line: " + args[i]);
      }
    }

    if (port == -1) {
      usage("Missing port");

    } else if (iterations == -1) {
      usage("Missing iterations");
    }

    Properties props = new Properties();
    props.setProperty(MCAST_PORT, "0");
    props.setProperty(LOG_LEVEL, "info");
    props.setProperty(LOCATORS, "localhost[" + port + "]");

    long totalConnect = 0;
    long totalDisconnect = 0;

    for (int i = 0; i < iterations; i++) {
      long start = System.currentTimeMillis();
      DistributedSystem system = DistributedSystem.connect(props);
      long delta = System.currentTimeMillis() - start;
      totalConnect += delta;
      out.println("** Connected to DistributedSystem " + "(took " + delta + " ms)");

      Thread.sleep(wait);

      start = System.currentTimeMillis();
      system.disconnect();
      delta = System.currentTimeMillis() - start;
      totalDisconnect += delta;
      out.println("** Disconnected from DistributedSystem " + "(took " + delta + " ms)");

    }

    out.println("** Average connect time took: " + (totalConnect / iterations) + " ms");
    out.println("** Average disconnect time took: " + (totalDisconnect / iterations) + " ms");

    ExitCode.NORMAL.doSystemExit();
  }
This program is used to measure the amount of time it takes to connect and re-connect to a
{@link DistributedSystem}.
geode-core/src/distributedTest/java/org/apache/geode/distributed/DistributedSystemConnectPerf.java