mirror of
https://github.com/logos-storage/das-research.git
synced 2026-01-11 09:33:11 +00:00
Implemented parallel processing of each runs
This commit is contained in:
parent
e98de5bf9f
commit
6bd277f54b
@ -4,6 +4,7 @@ import matplotlib.pyplot as plt
|
||||
import sys
|
||||
from datetime import datetime
|
||||
import os
|
||||
from joblib import Parallel, delayed
|
||||
|
||||
|
||||
def plotData(conf):
|
||||
@ -37,8 +38,6 @@ def getValidatorCountPerColumn(numberOfCols, numOfValidators, chiC):
|
||||
return validatorCountPerColumn
|
||||
|
||||
def runOnce(run_i, runs, deg, validatorCountPerCol, malNodesPercentage):
|
||||
print(f"Running: {run_i + 1} / {runs}")
|
||||
|
||||
isParted = False
|
||||
partCount = 0
|
||||
isPartedCount = 0
|
||||
@ -49,7 +48,6 @@ def runOnce(run_i, runs, deg, validatorCountPerCol, malNodesPercentage):
|
||||
partCount += 1
|
||||
|
||||
if isParted: isPartedCount += 1
|
||||
sys.stdout.write("\033[F")
|
||||
|
||||
return isPartedCount, partCount
|
||||
|
||||
@ -65,11 +63,9 @@ def study():
|
||||
for mal in mals:
|
||||
isPartedCount = partCount = 0
|
||||
validatorCountPerColumn = getValidatorCountPerColumn(numberOfColumns, numberOfValidators, custody)
|
||||
for _run in range(runs):
|
||||
_isPartedCount, _partCount = runOnce(_run, runs, deg, validatorCountPerColumn, mal)
|
||||
isPartedCount += _isPartedCount
|
||||
partCount += _partCount
|
||||
|
||||
results = Parallel(-1)(delayed(runOnce)(_run, runs, deg, validatorCountPerColumn, mal) for _run in range(runs))
|
||||
isPartedCount = sum([res[0] for res in results])
|
||||
partCount = sum([res[1] for res in results])
|
||||
partPercentages.append(isPartedCount * 100 / runs)
|
||||
avgDisconnectedCols.append(partCount / runs)
|
||||
print(f"Malicious Nodes: {mal}%, Partition Percentage: {partPercentages[-1]}, Avg. Partitions: {avgDisconnectedCols[-1]}")
|
||||
|
||||
@ -5,6 +5,7 @@ import sys
|
||||
import numpy as np
|
||||
from datetime import datetime
|
||||
import os
|
||||
from joblib import Parallel, delayed
|
||||
|
||||
|
||||
def plotData(conf):
|
||||
@ -38,8 +39,6 @@ def getValidatorCountPerColumn(numberOfCols, numOfValidators, chiC):
|
||||
return validatorCountPerColumn
|
||||
|
||||
def runOnce(run_i, runs, deg, validatorCountPerCol, malNodesPercentage):
|
||||
print(f"Running: {run_i + 1} / {runs}")
|
||||
|
||||
isParted = False
|
||||
partCount = 0
|
||||
isPartedCount = 0
|
||||
@ -50,7 +49,6 @@ def runOnce(run_i, runs, deg, validatorCountPerCol, malNodesPercentage):
|
||||
partCount += 1
|
||||
|
||||
if isParted: isPartedCount += 1
|
||||
sys.stdout.write("\033[F")
|
||||
|
||||
return isPartedCount, partCount
|
||||
|
||||
@ -66,11 +64,9 @@ def study():
|
||||
for mal in mals:
|
||||
isPartedCount = partCount = 0
|
||||
validatorCountPerColumn = getValidatorCountPerColumn(numberOfColumns, nv, custody)
|
||||
for _run in range(runs):
|
||||
_isPartedCount, _partCount = runOnce(_run, runs, deg, validatorCountPerColumn, mal)
|
||||
isPartedCount += _isPartedCount
|
||||
partCount += _partCount
|
||||
|
||||
results = Parallel(-1)(delayed(runOnce)(_run, runs, deg, validatorCountPerColumn, mal) for _run in range(runs))
|
||||
isPartedCount = sum([res[0] for res in results])
|
||||
partCount = sum([res[1] for res in results])
|
||||
partPercentages.append(isPartedCount * 100 / runs)
|
||||
avgDisconnectedCols.append(partCount / runs)
|
||||
print(f"Malicious Nodes: {mal}%, Partition Percentage: {partPercentages[-1]}, Avg. Partitions: {avgDisconnectedCols[-1]}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user