Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Expose Host Load for Java API through JNI
[simgrid.git] / examples / java / hostload / LoadRunner.java
1 /* Copyright (c) 2016-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 package hostload;
7
8 import org.simgrid.msg.*;
9 import org.simgrid.msg.Process;
10
11
12 public class LoadRunner extends Process {
13
14     public LoadRunner(Host host, String s) {
15     super(host, s);
16 }
17
18 public void display(){
19     Msg.info("Computed Flops "+                 getHost().getComputedFlops());
20     Msg.info("Current Load "+           getHost().getCurrentLoad());
21     Msg.info("GetLoad "+                getHost().getLoad());
22     Msg.info("AvgLoad "+                getHost().getAvgLoad());
23 }
24 @Override
25 public void main(String[] strings) throws MsgException {
26     double workload = 100E6;
27     Host host = getHost();
28     display();
29     // Run a task
30     Task task1 = new Task("t1", workload, 0);
31     task1.execute();
32     display();
33     double taskTime = Msg.getClock();
34     Msg.info("Task1 simulation time: "+ taskTime);
35
36     // Run a second task
37     new Task("t1", workload, 0).execute();
38
39     taskTime = Msg.getClock() - taskTime;
40     Msg.info("Task2 simulation time: "+ taskTime);
41     display();
42
43 }
44
45
46 }
47