Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
4d1e8d007e6f1b19ffdec9657e1e44f64e32458f
[simgrid.git] / examples / java / hostload / LoadRunner.java
1 /* Copyright (c) 2016-2019. 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("Speed="+getHost().getSpeed()+" flop/s");
20         Msg.info("Computed Flops "+             getHost().getComputedFlops());
21         Msg.info("AvgLoad "+            getHost().getAvgLoad());
22     }
23     @Override
24     public void main(String[] strings) throws MsgException {
25         display();
26         Msg.info("Sleep for 10 seconds");
27         waitFor(10);
28         display();
29
30         // Run a task
31         Task task1 = new Task("t1", 200E6, 0);
32         task1.execute();
33         display();
34         double taskTime = Msg.getClock();
35         Msg.info("Task1 simulation time: "+ taskTime);
36
37         // Run a second task
38         new Task("t1", 200E6, 0).execute();
39
40         taskTime = Msg.getClock() - taskTime;
41         Msg.info("Task2 simulation time: "+ taskTime);
42         display();
43
44     }
45
46
47 }