Package uk.ac.uea.threadr

Examples of uk.ac.uea.threadr.ThreadrResult


   * @throws Exception Not thrown in this method.
   */
  @Before
  public final void setUp() throws Exception {
   
    result = new ThreadrResult();
    tasks = new ReferenceTask[2];
    tasks[0] = new ReferenceTask();
    tasks[1] = new ReferenceTask();
  }
View Full Code Here


   * the conflicting result is not overwritten.
   */
  @Test
  public final void testCombineThreadrResult() {
   
    ThreadrResult other = new ThreadrResult();
    ReferenceReturnType ref = new ReferenceReturnType();
    ReferenceReturnType conflict = new ReferenceReturnType();   
   
    result.addTask(tasks[0]);
    result.addResult(tasks[0], ref);
   
    other.addTask(tasks[0]);
    other.addTask(tasks[1]);
    other.addResult(tasks[0], conflict);
    other.addResult(tasks[1], new ReferenceReturnType());
   
    result.combine(other);
    assertNotNull("Result became null", result);
    assertEquals("Incorrect number of tasks stored.", 2, result.size());
   
View Full Code Here

   * Fails if the conflicting result is overwritten.
   */
  @Test
  public final void testCombineThreadrResultNoOverwrite() {
   
    ThreadrResult other = new ThreadrResult();
    ReferenceReturnType ref = new ReferenceReturnType();
    ReferenceReturnType conflict = new ReferenceReturnType();   
   
    result.addTask(tasks[0]);
    result.addResult(tasks[0], ref);
   
    other.addTask(tasks[0]);
    other.addTask(tasks[1]);
    other.addResult(tasks[0], conflict);
    other.addResult(tasks[1], new ReferenceReturnType());
   
    result.combine(other, false);
    assertNotNull("Result became null", result);
    assertEquals("Incorrect number of tasks stored.", 2, result.size());
   
View Full Code Here

        threadr.addTasks(test);
        for (ThreadrTest t : test) {
          Threadr.logger.finer(t.toString());
        }
        startTime = System.currentTimeMillis();
        ThreadrResult results = threadr.execute();
        endTime = System.currentTimeMillis();
        diff2 = endTime - startTime;
        pars.add(diff2);
        double totalMem = threadr.getMemoryMonitor().getMaxUsedMemory(MemoryUnits.MEGABYTE);
        /* Get all the MemoryMonitors out from the results. */
        for (AbstractReturnType<?> result : results.getResults()) {
          /*
           * If the monitors are different, we must be looking at
           * another VM.
           */
          MemoryMonitor resultMon = (MemoryMonitor) result.getResult();
          if (!result.getResult().equals(threadr.getMemoryMonitor())) {
            totalMem += resultMon.getMaxUsedMemory(MemoryUnits.MEGABYTE);
          }
        }
        parMemUse.add(totalMem);
        Threadr.logger
            .fine(String
                .format("\nVirtual Machine tasks execution time %dms\n",
                    diff2));

        for (AbstractReturnType<?> result : results.getResults()) {
          Threadr.logger.finer(result.toString());
        }
        /* Work out the percentage increase in execution speed. */
        float percentage = (((float) (diff1 - diff2) / (float) diff1) * 100.0f);
        impsPar.add(percentage);
        Threadr.logger.fine(String.format(
            "\tImprovement: %03.02f%% \n", percentage));

        /* Set up and test threaded executions. */
        System.gc();
        threadr.reset();
        threadr.addTasks(test2);
        for (Test2 t : test2) {
          Threadr.logger.finer(t.toString());
        }
        startTime = System.currentTimeMillis();
        results = threadr.execute();
        endTime = System.currentTimeMillis();
        diff3 = endTime - startTime;
        thrs.add(diff3);
        totalMem = threadr.getMemoryMonitor().getMaxUsedMemory(MemoryUnits.MEGABYTE);
        for (AbstractReturnType<?> result : results.getResults()) {
          MemoryMonitor resultMon = (MemoryMonitor) result
              .getResult();
          if (!result.getResult().equals(threadr.getMemoryMonitor())) {
            totalMem += resultMon.getMaxUsedMemory(MemoryUnits.MEGABYTE);
          }
        }
        thrMemUse.add(totalMem);
        Threadr.logger.fine(String.format(
            "\tThreaded tasks execution time %dms\n", diff2));

        for (AbstractReturnType<?> result : results.getResults()) {
          Threadr.logger.finer(result.toString());
        }
        /* Work out the percentage increase in execution speed. */
        percentage = (((float) (diff1 - diff3) / (float) diff1) * 100.0f);
        impsThr.add(percentage);
 
View Full Code Here

    tasks.add(vmTask);
    tasks.add(unsafeTask);
   
    instance.addTasks(tasks);
    instance.setSequentialHandler(new PostSequentialHandler());
    ThreadrResult results = instance.execute();
    /* Sort the arrays copied earlier. */
    Arrays.sort(refData);
    Arrays.sort(refVMData);
    Arrays.sort(refUnsafeData);
   
    assertNotNull("Returned null result.", results);
    /* Check the stored tasks and results are all there. */
    assertEquals("Result task count incorrect.", tasks.size(),
        results.getTasks().size());
    assertEquals("Result tests count incorrect.", tasks.size(),
        results.getResults().size());
    /* Ensure the arrays returned match the reference arrays. */
    assertArrayEquals("Threaded result incorrect.", refData,
        (int[])results.getResult(task).getResult());
    assertArrayEquals("VM result incorrect.", refVMData,
        (int[])results.getResult(vmTask).getResult());
    assertArrayEquals("Sequential result incorrect.", refUnsafeData,
        (int[])results.getResult(unsafeTask).getResult());
  }
View Full Code Here

    }
   
    threadr.addTasks(stringTests);
    threadr.addTasks(test2Tests);
   
    ThreadrResult results = threadr.execute();
   
    for (AbstractReturnType<?> result : results.getResults()) {
      if (result != null) {
        System.out.println(result.toString());
      } else {
        System.out.println("Null result");
      }
View Full Code Here

    tasks.add(new FirstParallelSafe());
   
    Threadr threadr = new Threadr(tasks);
    threadr.enableLogging();
   
    ThreadrResult results = threadr.execute();
   
    for (Object result : results.getResults()) {
      try {
        SomeReturnType r = (SomeReturnType)result;
        if (r == null) {
          System.err.println("Result was null.");
          continue;
View Full Code Here

TOP

Related Classes of uk.ac.uea.threadr.ThreadrResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.