perfsim.helpers

Contents

perfsim.helpers#

Module contents#

Submodules#

perfsim.helpers.cost_calculator module#

class perfsim.helpers.cost_calculator.CostCalculator[source]#

Bases: object

Prevent instantiation of this class.

ALWAYS_ALLOC_CPU_PRICE_PER_VCPU_SEC = 1.8e-05#
ALWAYS_ALLOC_CPU_FREE_TIER_VPU_SEC_PER_MONTH = 240000#
ALWAYS_ALLOC_MEM_PRICE_PER_GB_SEC = 2e-06#
ALWAYS_ALLOC_MEM_FREE_TIER_GB_SEC_PER_MONTH = 450000#
ONLY_ALLOC_DURING_REQ_CPU_PRICE_PER_VCPU_SEC = 2.4e-05#
ONLY_ALLOC_DURING_REQ_CPU_PRICE_PER_VCPU_SEC_IDLE = 2.5e-06#
ONLY_ALLOC_DURING_REQ_FREE_TIER_VPU_SEC_PER_MONTH = 180000#
ONLY_ALLOC_DURING_REQ_MEM_PRICE_PER_GB_SEC = 2.5e-06#
ONLY_ALLOC_DURING_REQ_MEM_PRICE_PER_GB_SEC_IDLE = 2.5e-06#
ONLY_ALLOC_DURING_REQ_MEM_FREE_TIER_GB_SEC_PER_MONTH = 360000#
ONLY_ALLOC_DURING_REQ_PRICE = 4e-07#
ONLY_ALLOC_DURING_REQ_REQ_FREE_TIER_COUNT = 2000000#
concurrent_requests_per_container = 200#
requests = 3000000#
request_execution_time = 2#
static cost_for_always_allocated_instance(duration_in_sec, cores, memory, storage)[source]#

Calculate the cost of an instance that is always allocated.

Parameters:
  • duration_in_sec (float)

  • cores (int)

  • memory (int)

  • storage (int)

Return type:

float

Returns:

static cost_for_only_allocated_during_request_instance(duration_in_sec, cores, memory, storage, concurrent_requests, requests, request_exec_time_ns)[source]#

Calculate the cost of an instance that is only allocated during a request.

Parameters:
  • duration_in_sec (float)

  • cores (int)

  • memory (int)

  • storage (int)

  • concurrent_requests (int)

  • requests (int)

  • request_exec_time_ns (int)

Return type:

float

Returns:

perfsim.helpers.debug_dict module#

class perfsim.helpers.debug_dict.DebugDict[source]#

Bases: TypedDict

This class represents a dictionary of debug parameters.

debug: bool#
debug_level: int#
debug_file_location: Optional[str]#
log_cpu_events: bool#
log_timeline: bool#

perfsim.helpers.logger module#

class perfsim.helpers.logger.Logger(simulation=None)[source]#

Bases: object

This class represents a logger that logs the simulation events.

Parameters:

simulation (Simulation)

lb_timer = []#
tick_timer = []#
core_sorting_timer = []#
sim: Simulation#
print_traffic_details()[source]#
print_hosts_info()[source]#
print_microservices_info()[source]#
print_cluster_info()[source]#
print_subchains(scm)[source]#
Parameters:

scm (ServiceChainManager)

print_all()[source]#
log(msg, level=1)[source]#
Parameters:
  • msg (str)

  • level (int)

print_latencies(summary=False, detailed=True)[source]#
get_latencies_summary()[source]#

perfsim.helpers.plotter module#

class perfsim.helpers.plotter.Plotter[source]#

Bases: object

This class is responsible for plotting the simulation results.

static draw_topology(cluster)[source]#

Draw the topology of the cluster.

static draw_timeline_graph(results)[source]#

Draw the timeline graph.

Parameters:

results (SimulationScenarioResultDict)

static draw_figures(load_generator, scenario_name, show_events=True, path_to_save_results='/home/runner/work/perfsim/perfsim/docs/results/')[source]#

Draw the figures for the simulation results.

Parameters:
  • load_generator (LoadGenerator)

  • scenario_name (str)

  • show_events (bool)

  • path_to_save_results (str)

Return type:

None

static draw_graph(G, name, save_dir, output_type='html', with_labels=False, relabel=False, node_labels_map=None, show=False)[source]#

Draw a graph.

Parameters:
  • G

  • name

  • save_dir (str)

  • output_type (str)

  • with_labels (bool)

  • relabel (bool)

  • node_labels_map

  • show (bool)

Returns:

static convert_networkx_graph_to_cytoscape_json(G, edge_labels=None, node_style=None, edge_style=None, layout='euler')[source]#

Convert a NetworkX graph to a Cytoscape JSON object.

Parameters:
  • G

  • edge_labels (dict)

  • node_style (dict)

  • edge_style (dict)

  • layout

Return type:

str

Returns:

static get_cytoscape_template(ready_script)[source]#

Get the template for the Cytoscape graph.

Parameters:

ready_script (str)

Return type:

str

Returns:

static figures_to_html(figs, filename='dashboard.html')[source]#

Save a list of figures to an HTML file.

Parameters:
  • figs

  • filename

Returns:

perfsim.helpers.utils module#

class perfsim.helpers.utils.Utils[source]#

Bases: object

static mkdir_p(dir_path)[source]#

Creates a directory. equivalent to using mkdir -p on the command line

Parameters:

dir_path (str) – path to the directory

static save_file(file_path, content)[source]#

Save a file with the given content

Parameters:
  • file_path (str)

  • content (Any)

Returns:

static view_pydot(pdot)[source]#

View a pydot object in Jupyter notebook

Parameters:

pdot

Returns:

static save_results_json(result, save_dir)[source]#

Save the results in a JSON file and return the file path

Parameters:
  • result – Results to save

  • save_dir – The directory to save the file

Return type:

str

Returns:

Returns the file path

static write_a_line_to_a_log_file_static(log_file, time, txt)[source]#

Write a line to a log file

Parameters:
  • log_file (TextIO) – The log file

  • time (Union[str, int]) – The time

  • txt (str) – The text to write

Returns:

Returns None