コード例 #1
0
  /**
   * Starts the server going for these tests.
   *
   * @throws Exception If problems occur setting up the server.
   */
  @BeforeClass
  public static void setupServer() throws Exception {
    ParallelStressTest.server = Server.newTestInstance();

    ParallelStressTest.adminEmail = server.getServerProperties().get(ADMIN_EMAIL_KEY);
    ParallelStressTest.adminPassword = server.getServerProperties().get(ADMIN_PASSWORD_KEY);

    ParallelStressTest.manager = (DbManager) server.getContext().getAttributes().get("DbManager");
    String adminUserUri = manager.getUser(adminEmail).toUri(server);
    System.out.print("Creating test data...");
    ParallelStressTest.START_TIMESTAMP = Tstamp.makeTimestamp("2010-01-08T00:00:00.000-10:00");
    ParallelStressTest.END_TIMESTAMP = Tstamp.makeTimestamp("2010-02-08T00:00:00.000-10:00");

    SubSources subSources = new SubSources();
    for (int i = 0; i < NUM_SOURCES; i++) {
      Source source = new Source(sourceNames[i], adminUserUri, true);
      source.addProperty(new Property(Source.SUPPORTS_ENERGY_COUNTERS, "true"));
      sources[i] = source;
      sourceURIs[i] = source.toUri(server);
      subSources.getHref().add(sourceURIs[i]);
      ParallelStressTest.manager.storeSource(source);
    }
    ParallelStressTest.virtualSource =
        new Source(source11Name, adminUserUri, true, true, "", "", "", null, subSources);
    ParallelStressTest.manager.storeSource(virtualSource);

    Date testStart = new Date();
    parallelLoad(TEST_CLIENTS, START_TIMESTAMP, END_TIMESTAMP, 15);
    Date testEnd = new Date();
    double msElapsed = testEnd.getTime() - testStart.getTime();
    System.out.format("Time to insert data: %.1f ms%n", msElapsed);
  }
コード例 #2
0
  /**
   * Computes calculated energy for a virtual source many times and reports how long it took.
   *
   * @throws Exception If there are problems.
   */
  @Test
  public void testEnergyVirtualSource() throws Exception {
    final XMLGregorianCalendar startTime = Tstamp.incrementMinutes(START_TIMESTAMP, 1);
    final XMLGregorianCalendar endTime = Tstamp.incrementMinutes(END_TIMESTAMP, -30);
    final int iterations = 100;

    List<ClientThread> clients = new ArrayList<ClientThread>();
    for (int i = 0; i < TEST_CLIENTS; i++) {
      // Initialize clients
      clients.add(
          new ClientThread(i) {
            @Override
            public void run() {
              for (int j = 0; j < iterations; j++) {
                try {
                  client.getEnergyGenerated(DataGenerator.source11Name, startTime, endTime, 0);
                } catch (Exception e) {
                  e.printStackTrace();
                }
              }
            }
          });
    }

    double msElapsed = this.runClients(clients);
    System.out.format(
        "Time to compute energy for virtual source using counters generated %d times: %.1f ms%n",
        iterations, msElapsed);
    System.out.format(
        "Mean time to compute energy for virtual source using counters: %.1f ms%n",
        msElapsed / iterations);
  }
コード例 #3
0
 /**
  * Computes interpolated power for a virtual source many times and reports how long it took.
  *
  * @throws Exception If there are problems.
  */
 public void testInterpolatedPowerVirtualSource() throws Exception {
   final XMLGregorianCalendar timestamp = Tstamp.makeTimestamp("2010-01-08T12:03:07.000-10:00");
   final int iterations = 1000;
   List<ClientThread> clients = new ArrayList<ClientThread>();
   for (int i = 0; i < TEST_CLIENTS; i++) {
     clients.add(
         new ClientThread(i) {
           @Override
           public void run() {
             for (int j = 0; j < iterations; j++) {
               try {
                 client.getPowerGenerated(DataGenerator.source11Name, timestamp);
               } catch (Exception e) {
                 e.printStackTrace();
               }
             }
           }
         });
   }
   double msElapsed = this.runClients(clients);
   System.out.format(
       "Time to calculate interpolated power for virtual source generated %d times: %.1f ms%n",
       iterations, msElapsed);
   System.out.format(
       "Mean time to calculate interpolated power for virtual source: %.1f ms%n",
       msElapsed / iterations);
 }
コード例 #4
0
  /**
   * Computes interpolated power for a single source many times and reports how long it took.
   *
   * @throws Exception If there are problems.
   */
  @Test
  public void testInterpolatedPowerSingleSource() throws Exception {
    final XMLGregorianCalendar timestamp = Tstamp.makeTimestamp("2010-01-08T12:03:07.000-10:00");
    final int iterations = 1000;
    List<ClientThread> clients = new ArrayList<ClientThread>();
    for (int i = 0; i < TEST_CLIENTS; i++) {
      // Spawn clients
      clients.add(
          new ClientThread(i) {
            @Override
            public void run() {
              for (int j = 0; j < iterations; j++) {
                try {
                  client.getPowerGenerated(DataGenerator.getSourceName(0), timestamp);
                } catch (Exception e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            }
          });
    }
    double msElapsed = this.runClients(clients);

    System.out.format(
        "Time to calculate interpolated power generated %d times: %.1f ms%n", 1000, msElapsed);
    System.out.format("Mean time to calculate interpolated power: %.1f ms%n", msElapsed / 1000);
  }