Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / examples / deprecated / java / energy / consumption / EnergyConsumer.java
1 /* Copyright (c) 2006-2021. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 package energy.consumption;
8
9 import org.simgrid.msg.Msg;
10 import org.simgrid.msg.Task;
11 import org.simgrid.msg.Process;
12 import org.simgrid.msg.MsgException;
13 import org.simgrid.msg.HostNotFoundException;
14
15 public class EnergyConsumer extends Process {
16   public EnergyConsumer(String hostname, String name) throws HostNotFoundException {
17     super(hostname,name);
18   }
19
20   public void main(String[] args) throws MsgException {
21      Msg.info("Energetic profile: " + getHost().getProperty("wattage_per_state"));
22      Msg.info("Initial peak speed= " + getHost().getSpeed() + " flop/s; Energy dissipated = "
23               + getHost().getConsumedEnergy() + " J");
24
25      this.waitFor(10);
26      Msg.info("Currently consumed energy after sleeping 10 sec: "+getHost().getConsumedEnergy());
27      new Task(null, 1E9, 0).execute();
28      Msg.info("Currently consumed energy after executing 1E9 flops: "+getHost().getConsumedEnergy());
29   }
30 }