Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bin block num #389

Merged
merged 2 commits into from
Dec 12, 2024
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
34 changes: 28 additions & 6 deletions tests/ten/ten_per_005/Input/gnuplot.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ set label "{/Courier:Bold=13 Environment}: ".ARG5 left at screen 0.59, screen 0.
set label "{/Courier:Bold=13 Transactions}: ".ARG6 left at screen 0.59, screen 0.850
set label "{/Courier:Bold=13 Duration}: ".ARG7 left at screen 0.59, screen 0.825
set label "{/Courier:Bold=13 Clients}: ".ARG8 left at screen 0.59, screen 0.800
stats "clients.bin" using 1:2 nooutput
stats "clients_ts.bin" using 1:2 nooutput name "TS_STATS"
stats "clients_bh.bin" using 1:2 nooutput name "BH_STATS"

# plot1
set grid z dt '- -' lc 'black' lw 2
Expand All @@ -28,7 +29,7 @@ set boxwidth 1
set style fill solid 0.5
set xlabel "Time (seconds)" font "Courier,12" rotate parallel
set zlabel "Transactions" font "Courier,12" offset 1,0 rotate parallel
splot for [client = (ARG8+1) : 2 : -1 ] 'clients_all.bin' using 1:(client):(column(client)) with boxes
splot for [client = (ARG8+1) : 2 : -1 ] 'clients_all_ts.bin' using 1:(client):(column(client)) with boxes

# plot 2
unset grid
Expand All @@ -43,9 +44,30 @@ set ytics font "Courier,11"
set key font 'Courier,10'
set key right top
set size 0.5, 0.45
set origin 0.0, 0.04
set yr [0: ((STATS_max_y)*1.1)]
set title "{/Arial:Bold=13 Binned Transactions}"
set origin 0.0, 0.05
set yr [0: ((TS_STATS_max_y)*1.1)]
set title "{/Arial:Bold=13 Binned Transactions (timestamp)}"
set xlabel "Time (seconds)" font "Courier,12"
set ylabel "Transactions" font "Courier,12" offset 1,0
plot "clients.bin" using 1:2 with boxes ls 1 title "Binned", "" using 1:(STATS_mean_y) with lines title "Average"
plot "clients_ts.bin" using 1:2 with boxes ls 1 title "Binned", "" using 1:(TS_STATS_mean_y) with lines title "Average"

# plot 3
unset grid
unset yr
unset ytics
unset xlabel
unset zlabel
unset xr
set style line 1 lc rgb 'gray30' lt 1 lw 1.2
set style fill solid 0.3 border rgb 'grey30'
set xtics font "Courier,11"
set ytics font "Courier,11"
set key font 'Courier,10'
set key right top
set size 0.5, 0.45
set origin 0.5, 0.05
set yr [0: ((BH_STATS_max_y)*1.1)]
set title "{/Arial:Bold=13 Binned Transactions (Block height)}"
set xlabel "Block height" font "Courier,12"
set ylabel "Transactions" font "Courier,12" offset 1,0
plot "clients_bh.bin" using 1:2 with boxes ls 1 title "Binned", "" using 1:(BH_STATS_mean_y) with lines title "Average"
6 changes: 3 additions & 3 deletions tests/ten/ten_per_005/Input/storage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def run(name, chainId, web3, account, contract, num_iterations, gas_limit):
logging.info('Constructing binned data from the transaction receipts')
with open('%s.log' % name, 'w') as fp:
for receipt in receipts:
block_number_deploy = web3.eth.get_transaction(receipt[0]).blockNumber
timestamp = int(web3.eth.get_block(block_number_deploy).timestamp)
fp.write('%d %d\n' % (receipt[1], timestamp))
block_number = web3.eth.get_transaction(receipt[0]).blockNumber
timestamp = int(web3.eth.get_block(block_number).timestamp)
fp.write('%d %d %d\n' % (receipt[1], timestamp, block_number))

logging.info('Client %s completed', name)
logging.shutdown()
Expand Down
62 changes: 39 additions & 23 deletions tests/ten/ten_per_005/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class PySysTest(TenNetworkTest):
ITERATIONS = 2048 # iterations per client
ITERATIONS = 1024 # iterations per client
CLIENTS = 4 # the number of concurrent clients

def __init__(self, descriptor, outsubdir, runner):
Expand Down Expand Up @@ -40,34 +40,41 @@ def execute(self):
self.assertGrep(file=stdout, expr='Error sending raw transaction', contains=False, abortOnError=False)
txs_sent += self.txs_sent(file=stdout)

# process and graph the output
# process (data is an array of each client results - each is an array of tuple (nonce, ts, block height))
data = [self.load_data('client_%d.log' % i) for i in range(self.CLIENTS)]
first = int(data[0][0][1])
last = int(data[-1][-1][1])

data_binned = [self.bin_data(first, last, d, OrderedDict()) for d in data]
with open(os.path.join(self.output, 'clients_all.bin'), 'w') as fp:
for t in range(0, last + 1 - first):
fp.write('%d %s\n' % (t, ' '.join([str(d[t]) for d in data_binned])))

heights = []
with open(os.path.join(self.output, 'clients.bin'), 'w') as fp:
for t in range(0, last + 1 - first):
height = sum([d[t] for d in data_binned])
heights.append(height)

# bin based on timestamps (both for each client, and across all clients)
first_ts = int(data[0][0][1]) # first client, first data, ts
last_ts = int(data[-1][-1][1]) # last client, last data, ts
duration = last_ts - first_ts
data_binned_ts = [self.bin_timestamp_data(first_ts, last_ts, d, OrderedDict()) for d in data]
with open(os.path.join(self.output, 'clients_all_ts.bin'), 'w') as fp:
for t in range(0, last_ts + 1 - first_ts):
fp.write('%d %s\n' % (t, ' '.join([str(d[t]) for d in data_binned_ts])))

with open(os.path.join(self.output, 'clients_ts.bin'), 'w') as fp:
for t in range(0, last_ts + 1 - first_ts):
height = sum([d[t] for d in data_binned_ts])
fp.write('%d %d\n' % (t, height))

# bin based on block height (across all clients)
first_bh = int(data[0][0][2]) # first client, first data, block height
last_bh = int(data[-1][-1][2]) # last client, last data, block height
data_binned_bh = [self.bin_block_height_data(first_bh, last_bh, d, OrderedDict()) for d in data]
with open(os.path.join(self.output, 'clients_bh.bin'), 'w') as fp:
for t in range(first_bh, last_bh + 1):
height = sum([d[t] for d in data_binned_bh])
fp.write('%d %d\n' % (t, height))
average = '%.2f' % (float(sum(heights)) / len(heights))

# plot out the results
branch = GnuplotHelper.buildInfo().branch
duration = last - first
date = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
GnuplotHelper.graph(self, os.path.join(self.input, 'gnuplot.in'),
branch, date,
str(self.mode), str(txs_sent), str(duration), '%d' % self.CLIENTS)

# persist the result
self.results_db.insert_result(self.descriptor.id, self.mode, int(time.time()), average)
self.results_db.insert_result(self.descriptor.id, self.mode, int(time.time()), float(txs_sent)/float(duration))

# passed if no failures (though pdf output should be reviewed manually)
self.addOutcome(PASSED)
Expand Down Expand Up @@ -101,13 +108,22 @@ def load_data(self, file):
data = []
with open(os.path.join(self.output, file), 'r') as fp:
for line in fp.readlines():
nonce, timestamp = line.split()
data.append((nonce, int(timestamp)))
nonce, timestamp, block_num = line.split()
data.append((nonce, int(timestamp), int(block_num)))
return data

def bin_data(self, first, last, data, binned_data):
"""Bin a client transaction data and offset the time. """
@staticmethod
def bin_timestamp_data(first, last, data, binned_data):
"""Bin a client transaction data or timestamp, and offset the time. """
b = OrderedDict()
for _, t in data: b[t] = 1 if t not in b else b[t] + 1
for _, t, _ in data: b[t] = 1 if t not in b else b[t] + 1
for t in range(first, last + 1): binned_data[t - first] = 0 if t not in b else b[t]
return binned_data

@staticmethod
def bin_block_height_data(first, last, data, binned_data):
"""Bin a client transaction data for block height. """
b = OrderedDict()
for _, _, h in data: b[h] = 1 if h not in b else b[h] + 1
for h in range(first, last + 1): binned_data[h] = 0 if h not in b else b[h]
return binned_data
2 changes: 1 addition & 1 deletion tests/ten/ten_per_012/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


class PySysTest(TenNetworkTest):
ITERATIONS = 2 * 1024 # iterations per client
ITERATIONS = 2048 # iterations per client

def execute(self):
# connect to the network and determine constants and funds required to run the test
Expand Down