Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions src/main/java/org/cloudsimplus/benchmarks/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,20 @@

import java.util.concurrent.TimeUnit;

/**
* Configures parameters for the JMH Micro-benchmarking framework and starts
* execution of all benchmark classes.
*
* To run the benchmarks, clean and build the main project,
* then, clean and build this project. Finally, run this class.
*
* @author Manoel Campos da Silva Filho
* @see <a href="http://tutorials.jenkov.com/java-performance/jmh.html">JMH - Java Micro-benchmark Harness Tutorial</a>
* @see <a href="http://java-performance.info/jmh/">Java Performance: JMH</a>
*/
/// Configures parameters for the JMH Micro-benchmarking framework and starts
/// execution of all benchmark classes.
///
/// To run the benchmarks, clean and build the main project,
/// then, clean and build this project. Finally, run this class.
///
/// @author Manoel Campos da Silva Filho
/// @see <a href="http://tutorials.jenkov.com/java-performance/jmh.html">JMH - Java Micro-benchmark Harness Tutorial</a>
/// @see <a href="http://java-performance.info/jmh/">Java Performance: JMH</a>
public final class Run {
/**
* Regex to identify classes with benchmarks that have to be executed.
*/
/// Regex to identify classes with benchmarks that have to be executed.
private static final String TEST_CLASSES_REGEX = "org.cloudsimplus.";

/**
* A private constructor to avoid class instantiation.
*/
/// A private constructor to avoid class instantiation.
private Run(){}

public static void main(String[] args) throws RunnerException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,22 @@

import static java.util.stream.Collectors.toList;

/**
* A benchmark that executes a simulation scenario
* multiple times to assess the scalability of CloudSim Plus,
* by means of simulation execution time.
* Each simulation run increases the number of Hosts, VMs and Cloudlets.
* That benchmark doesn't use JHM benchmarking framework.
*
* @author Manoel Campos da Silva Filho
* @since CloudSim Plus 6.2.0
*/
/// A benchmark that executes a simulation scenario
/// multiple times to assess the scalability of CloudSim Plus,
/// by means of simulation execution time.
/// Each simulation run increases the number of Hosts, VMs and Cloudlets.
/// That benchmark doesn't use JHM benchmarking framework.
///
/// @author Manoel Campos da Silva Filho
/// @since CloudSim Plus 6.2.0
public class SimulationTimeBenchmark {
public static final int SIMULATIONS = 4;
public static final int HOSTS_INCREMENT = 100;
public static final int INITIAL_HOSTS_NUMBER = 100;
private static final int HOST_PES = 64;

private static final int VM_PES = 1;
/**
* Value used to multiply the number of VMs to get the number of Cloudlets.
*/
/// Value used to multiply the number of VMs to get the number of Cloudlets.
private static final int VMS_MULTIPLIER = 55;

private static final int CLOUDLET_PES = 1;
Expand Down Expand Up @@ -130,9 +126,7 @@ private SimulationTimeBenchmark(final int hostsNumber) {
this.finishTimeSecs = TimeUtil.elapsedSeconds(startTimeSecs);
}

/**
* Creates a Datacenter and its Hosts.
*/
/// Creates a Datacenter and its Hosts.
private Datacenter createDatacenter() {
final List<Host> hostList = new ArrayList<>(hostsNumber);
for(int i = 0; i < hostsNumber; i++) {
Expand Down Expand Up @@ -163,9 +157,7 @@ private Host createHost() {
return new HostSimple(ram, bw, storage, peList);
}

/**
* Creates a list of VMs.
*/
/// Creates a list of VMs.
private List<Vm> createVms() {
final List<Vm> list = new ArrayList<>(vmsNumber);
for (int i = 0; i < vmsNumber; i++) {
Expand All @@ -178,9 +170,7 @@ private List<Vm> createVms() {
return list;
}

/**
* Creates a list of Cloudlets.
*/
/// Creates a list of Cloudlets.
private List<Cloudlet> createCloudlets() {
final List<Cloudlet> list = new ArrayList<>(cloudletsNumber);

Expand Down
31 changes: 26 additions & 5 deletions src/main/java/org/cloudsimplus/benchmarks/package-info.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
/**
* A set of benchmarks to assess performance of implemented
* <a href="http://www.wikiwand.com/en/Heuristic">Heuristics</a> that solves a given
* optimization problem.
/*
* CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for
* Modeling and Simulation of Cloud Computing Infrastructures and Services.
* http://cloudsimplus.org
*
* @author Manoel Campos da Silva Filho
* Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and
* the Instituto Federal de Educa莽茫o Ci锚ncia e Tecnologia do Tocantins (IFTO, Brazil).
*
* This file is part of CloudSim Plus.
*
* CloudSim Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CloudSim Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CloudSim Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/// A set of benchmarks to assess performance of implemented
/// [Heuristics](http://www.wikiwand.com/en/Heuristic) that solves a given
/// optimization problem.
///
/// @author Manoel Campos da Silva Filho
@NullMarked
package org.cloudsimplus.benchmarks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@

import java.util.*;

/**
* A set of benchmarks to measure the performance of managing
* a collection of ordered {@link SimEvent} using:
* - a {@link java.util.SortedSet};
* - a regular {@link java.util.LinkedList} and
* custom algorithms to ensure order when adding elements.
*
* @author Manoel Campos da Silva Filho
*/
/// A set of benchmarks to measure the performance of managing
/// a collection of ordered [SimEvent] using:
/// - a [java.util.SortedSet];
/// - a regular [java.util.LinkedList] and
/// custom algorithms to ensure order when adding elements.
///
/// @author Manoel Campos da Silva Filho
@BenchmarkMode({Mode.AverageTime, Mode.Throughput})
@State(Scope.Thread)
public class SortedSetVsLinkedList {
Expand All @@ -54,13 +52,11 @@ public class SortedSetVsLinkedList {
private int serial;
@SuppressWarnings("NullAway.Init") // initialized in doSetup()
private RandomGenerator prng;
/**
* Defines the probability to increase or not the {@link #time}
* randomly.
* Some benchmarks always increase the time while other ones
* increase just when a pseudo-random number if lower
* than the given probability.
*/
/// Defines the probability to increase or not the [#time]
/// randomly.
/// Some benchmarks always increase the time while other ones
/// increase just when a pseudo-random number if lower
/// than the given probability.
private static final double VALUE_INCREASE_PROBABILITY = 0.7;

@Setup(Level.Iteration)
Expand All @@ -73,32 +69,26 @@ public void doSetup() {
maxTime = 0;
}

/**
* Adds an always-incremented value into a {@link TreeSet}.
* @return
*/
/// Adds an always-incremented value into a [TreeSet].
/// @return
@Benchmark
public Collection<SimEvent> testSortedSetAdd() {
return sortedSetAdd(++time);
}

/**
* Adds a value into a {@link TreeSet} which
* is increased just with a probability defined by {@link #VALUE_INCREASE_PROBABILITY}.
* This way, we can benchmark the {@link TreeSet} and {@link LinkedList} when
* events for the same time are generated consecutively.
* @return
*/
/// Adds a value into a [TreeSet] which
/// is increased just with a probability defined by [#VALUE_INCREASE_PROBABILITY].
/// This way, we can benchmark the [TreeSet] and [LinkedList] when
/// events for the same time are generated consecutively.
/// @return
@Benchmark
public Collection<SimEvent> testSortedSetAddRandomIncrement() {
return sortedSetAdd(increaseTimeRandomly());
}

/**
* Adds an always-incremented value into a {@link LinkedList}
* that uses the CloudSimPlus's custom implementation to ensure order.
* @return
*/
/// Adds an always-incremented value into a [LinkedList]
/// that uses the CloudSimPlus's custom implementation to ensure order.
/// @return
@Benchmark
public Collection<SimEvent> testCustomLinkedListAdd() {
return sortedLinkedListAdd(++time);
Expand All @@ -109,14 +99,12 @@ public Collection<SimEvent> testCustomLinkedListAddReversed() {
return sortedLinkedListAddReversed(++time);
}

/**
* Adds a value into a {@link LinkedList} which
* is increased just with a probability defined by {@link #VALUE_INCREASE_PROBABILITY}.
* This way, we can benchmark the {@link TreeSet} and {@link LinkedList} when
* events for the same time are generated consecutively.
* Such a {@link LinkedList} uses the CloudSimPlus's custom implementation to ensure order.
* @return
*/
/// Adds a value into a [LinkedList] which
/// is increased just with a probability defined by [#VALUE_INCREASE_PROBABILITY].
/// This way, we can benchmark the [TreeSet] and [LinkedList] when
/// events for the same time are generated consecutively.
/// Such a [LinkedList] uses the CloudSimPlus's custom implementation to ensure order.
/// @return
@Benchmark
public Collection<SimEvent> testCustomLinkedListAddRandomIncrement() {
return sortedLinkedListAdd(increaseTimeRandomly());
Expand All @@ -133,11 +121,9 @@ private Collection<SimEvent> sortedSetAdd(final double time) {
return sortedSet;
}

/**
* CloudSimPlus's DeferredQueue uses a LinkedList and a custom
* algorithm to ensure order when adding elements.
* @return
*/
/// CloudSimPlus's DeferredQueue uses a LinkedList and a custom
/// algorithm to ensure order when adding elements.
/// @return
private Collection<SimEvent> sortedLinkedListAdd(final double time) {
if (time >= maxTime) {
linkedList.add(createEvent(time));
Expand All @@ -158,13 +144,11 @@ private Collection<SimEvent> sortedLinkedListAdd(final double time) {
return linkedList;
}

/**
* An alternative to CloudSimPlus's DeferredQueue that ensures order when adding
* elements into a LinkedList. However, this implementations start looking
* for the position to add an element from the end of the list,
* since the time of the event is usually higher then the previous time.
* @return
*/
/// An alternative to CloudSimPlus's DeferredQueue that ensures order when adding
/// elements into a LinkedList. However, this implementations start looking
/// for the position to add an element from the end of the list,
/// since the time of the event is usually higher then the previous time.
/// @return
private Collection<SimEvent> sortedLinkedListAddReversed(final double time) {
if (time >= maxTime) {
linkedList.add(createEvent(time));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@

import java.util.stream.IntStream;

/**
* A set of benchmarks for the {@link CloudletToVmMappingSolution} class.
*
* @author Manoel Campos da Silva Filho
*/
/// A set of benchmarks for the [CloudletToVmMappingSolution] class.
///
/// @author Manoel Campos da Silva Filho
@BenchmarkMode({Mode.AverageTime, Mode.Throughput})
@State(Scope.Thread)
public class CloudletToVmMappingSolutionBenchmark {
Expand Down Expand Up @@ -80,15 +78,13 @@ public double testGetCostWhenFirstCall() {
return instance1.getCost(true);
}

/**
* The second time the getCost method is called
* without changing Cloudlets to Vm's mapping,
* the fitness will be the same and will not be computed again.
* The first time the method is called is in the
* {@link #doSetup()} method.
*
* @return the cost value
*/
/// The second time the getCost method is called
/// without changing Cloudlets to Vm's mapping,
/// the fitness will be the same and will not be computed again.
/// The first time the method is called is in the
/// [#doSetup()] method.
///
/// @return the cost value
@Benchmark
public double testGetCostWhenSecondCall() {
return instance2.getCost();
Expand Down
35 changes: 29 additions & 6 deletions src/main/java/org/cloudsimplus/heuristics/package-info.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
/**
* A set of benchmarks created using the
* <a href="http://openjdk.java.net/projects/code-tools/jmh/">JMH (Java Microbenchmark Harness framework)</a>
* to assess performance of CloudSim Plus features.
/*
* CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for
* Modeling and Simulation of Cloud Computing Infrastructures and Services.
* http://cloudsimplus.org
*
* <p>The main class that starts the benchmarks is the {@link org.cloudsimplus.benchmarks.Run}</p>.
* @author Manoel Campos da Silva Filho
* Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and
* the Instituto Federal de Educa莽茫o Ci锚ncia e Tecnologia do Tocantins (IFTO, Brazil).
*
* This file is part of CloudSim Plus.
*
* CloudSim Plus is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CloudSim Plus is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CloudSim Plus. If not, see <http://www.gnu.org/licenses/>.
*/
/// A set of benchmarks created using the
/// [JMH (Java Microbenchmark Harness framework)](http://openjdk.java.net/projects/code-tools/jmh/)
/// to assess performance of CloudSim Plus features.
///
/// The main class that starts the benchmarks is the [org.cloudsimplus.benchmarks.Run]
///
/// .
/// @author Manoel Campos da Silva Filho
@NullMarked
package org.cloudsimplus.heuristics;

Expand Down
Loading