JPPF, java, parallel computing, distributed computing, grid computing, parallel, distributed, cluster, grid, cloud, open source, android, .net
JPPF

The open source
grid computing
solution

 Home   About   Features   Download   Documentation   Forums 
October 21, 2019, 01:50:58 AM *
Welcome,
Please login or register.

Login with username, password and session length
Advanced search  
News: New users, please read this message. Thank you!
  Home Help Search Login Register  
Pages: [1]   Go Down

Author Topic: speed difference on JPPF vs PC  (Read 3466 times)

electro2

  • JPPF Padawan
  • *
  • Posts: 1
speed difference on JPPF vs PC
« on: June 06, 2011, 04:41:58 PM »

What is the speed difference between running a single task directly on a PC and running it remotely using JPPF on the same PC?
Is it possible calculating this value approximately?
Logged

lolo

  • Administrator
  • JPPF Council Member
  • *****
  • Posts: 2256
    • JPPF Web site
Re: speed difference on JPPF vs PC
« Reply #1 on: June 07, 2011, 06:27:03 AM »

Hello,

The best way to measure the difference between in-JVM and remote execution would probably be to benchmark them.

You could write code like this to do it:

Code: [Select]
import java.util.List;
import org.jppf.client.*;
import org.jppf.server.protocol.JPPFTask;

public class Benchmark {
  private static JPPFClient client;

  public static void main(String...args) {
    try {
      client = new JPPFClient();
      int iterations = 10;
      double avgMillis = (executeLocally(iterations) / 1e6) / iterations;
      System.out.println("Average local execution time in millis: " + avgMillis);
      avgMillis = (executeRemotely(iterations) / 1e6) / iterations;
      System.out.println("Average remote execution time in millis: " + avgMillis);
    }
    catch(Exception e) {
      e.printStackTrace();
    }
    finally {
      if (client != null) client.close();
    }
  }

  public static long executeLocally(int iterations) throws Exception {
    long start = System.nanoTime();
    for (int i=0; i<iterations; i++) createTask().run();
    // total elapsed time in nanoseconds
    return System.nanoTime() - start;
  }

  public static long executeRemotely(int iterations) throws Exception {
    long start = System.nanoTime();
    for (int i=0; i<iterations; i++) {
      JPPFJob job = new JPPFJob();
      job.addTask(createTask());
      List<JPPFTask> results = client.submit(job);
    }
    // total elapsed time in nanoseconds
    return System.nanoTime() - start;
  }

  public static JPPFTask createTask() {
    // create a JPPF task
    JPPFTask task = ...;
    return task;
  }
}

I hope this helps,
-Laurent
Logged
Pages: [1]   Go Up
 
JPPF Powered by SMF 2.0 RC5 | SMF © 2006–2011, Simple Machines LLC Get JPPF at SourceForge.net. Fast, secure and Free Open Source software downloads