public void run()

in benchmarks/latency-comparison/java/src/main/java/com/google/cloud/spanner/pgadapter/latency/LatencyBenchmark.java [115:194]


  public void run(CommandLine commandLine) {
    Instant runTime = Instant.now();
    int clients =
        commandLine.hasOption('c') ? Integer.parseInt(commandLine.getOptionValue('c')) : 16;
    int operations =
        commandLine.hasOption('o') ? Integer.parseInt(commandLine.getOptionValue('o')) : 1000;
    int waitMillis =
        commandLine.hasOption('w') ? Integer.parseInt(commandLine.getOptionValue('w')) : 0;
    TransactionType transactionType =
        commandLine.hasOption('t')
            ? TransactionType.valueOf(commandLine.getOptionValue('t').toUpperCase(Locale.ENGLISH))
            : TransactionType.READ_ONLY;
    boolean runPg = !commandLine.hasOption("skip_pg");
    boolean runJdbc = !commandLine.hasOption("skip_jdbc");
    boolean runSpanner = !commandLine.hasOption("skip_spanner");
    boolean useUnixDomainSockets = commandLine.hasOption("uds");
    String name = commandLine.getOptionValue("name");
    int warmupIterations =
        commandLine.hasOption("warmup")
            ? Integer.parseInt(commandLine.getOptionValue("warmup"))
            : 60 * 1000 / 5;

    System.out.println();
    System.out.println("Running benchmark with the following options");
    System.out.printf("Database: %s\n", databaseId);
    System.out.printf("Clients: %d\n", clients);
    System.out.printf("Operations: %d\n", operations);
    System.out.printf("Transaction type: %s\n", transactionType);
    System.out.printf("Wait between queries: %dms\n", waitMillis);

    if (warmupIterations > 0) {
      System.out.println();
      System.out.println("Running warmup script");
      PgJdbcRunner pgJdbcRunner = new PgJdbcRunner(databaseId, false);
      int warmupClients = Runtime.getRuntime().availableProcessors();
      pgJdbcRunner.execute(transactionType, warmupClients, warmupIterations, 0);
    }

    List<Duration> pgJdbcResults = null;
    if (runPg) {
      System.out.println();
      System.out.println("Running benchmark for PostgreSQL JDBC driver using TCP");
      PgJdbcRunner pgJdbcRunner = new PgJdbcRunner(databaseId, false);
      pgJdbcResults = pgJdbcRunner.execute(transactionType, clients, operations, waitMillis);
    }
    List<Duration> pgJdbcUdsResults = null;
    if (runPg && useUnixDomainSockets) {
      System.out.println();
      System.out.println("Running benchmark for PostgreSQL JDBC driver using Unix Domain Sockets");
      PgJdbcRunner pgJdbcRunner = new PgJdbcRunner(databaseId, true);
      pgJdbcUdsResults = pgJdbcRunner.execute(transactionType, clients, operations, waitMillis);
    }

    List<Duration> jdbcResults = null;
    if (runJdbc) {
      System.out.println();
      System.out.println("Running benchmark for Cloud Spanner JDBC driver");
      JdbcRunner jdbcRunner = new JdbcRunner(databaseId);
      jdbcResults = jdbcRunner.execute(transactionType, clients, operations, waitMillis);
    }

    List<Duration> javaClientResults = null;
    if (runSpanner) {
      System.out.println();
      System.out.println("Running benchmark for Java Client Library");
      JavaClientRunner javaClientRunner = new JavaClientRunner(databaseId);
      javaClientResults =
          javaClientRunner.execute(transactionType, clients, operations, waitMillis);
    }

    printResults("PostgreSQL JDBC Driver (TCP)", pgJdbcResults);
    printResults("PostgreSQL JDBC Driver (Unix Domain Sockets)", pgJdbcUdsResults);
    printResults("Cloud Spanner JDBC Driver", jdbcResults);
    printResults("Java Client Library", javaClientResults);

    if (commandLine.hasOption('s')) {
      saveResults(
          runTime, name, clients, operations, pgJdbcResults, jdbcResults, javaClientResults);
    }
  }