From 894792f9553937be17a44d2f83b3c1ca138e1397 Mon Sep 17 00:00:00 2001 From: Moray Grieve Date: Thu, 12 Dec 2024 18:40:20 +0000 Subject: [PATCH 1/2] Bin by bock height --- tests/ten/ten_per_005/Input/gnuplot.in | 33 ++++++++-- tests/ten/ten_per_005/Input/storage_client.py | 6 +- tests/ten/ten_per_005/run.py | 64 ++++++++++++------- tests/ten/ten_per_012/run.py | 2 +- 4 files changed, 72 insertions(+), 33 deletions(-) diff --git a/tests/ten/ten_per_005/Input/gnuplot.in b/tests/ten/ten_per_005/Input/gnuplot.in index 6f965144..08298718 100644 --- a/tests/ten/ten_per_005/Input/gnuplot.in +++ b/tests/ten/ten_per_005/Input/gnuplot.in @@ -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 @@ -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 @@ -43,9 +44,29 @@ 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 +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" diff --git a/tests/ten/ten_per_005/Input/storage_client.py b/tests/ten/ten_per_005/Input/storage_client.py index c6d15724..a2a5ed6e 100644 --- a/tests/ten/ten_per_005/Input/storage_client.py +++ b/tests/ten/ten_per_005/Input/storage_client.py @@ -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() diff --git a/tests/ten/ten_per_005/run.py b/tests/ten/ten_per_005/run.py index 0a5288a7..91b1a2fb 100644 --- a/tests/ten/ten_per_005/run.py +++ b/tests/ten/ten_per_005/run.py @@ -8,7 +8,7 @@ class PySysTest(TenNetworkTest): - ITERATIONS = 2048 # iterations per client + ITERATIONS = 128 # iterations per client CLIENTS = 4 # the number of concurrent clients def __init__(self, descriptor, outsubdir, runner): @@ -40,34 +40,44 @@ 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(d, OrderedDict()) for d in data] + self.log.info(first_bh) + self.log.info(last_bh) + self.log.info(data_binned_bh) + with open(os.path.join(self.output, 'clients_bh.bin'), 'w') as fp: + for t in range(0, last_bh + 1 - first_bh): + 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) @@ -101,13 +111,21 @@ 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(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 + return binned_data \ No newline at end of file diff --git a/tests/ten/ten_per_012/run.py b/tests/ten/ten_per_012/run.py index 52f5ba45..96dc3bc2 100644 --- a/tests/ten/ten_per_012/run.py +++ b/tests/ten/ten_per_012/run.py @@ -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 From 1ac8c7f57b5271f8c34273882ca1d30939b52e26 Mon Sep 17 00:00:00 2001 From: Moray Grieve Date: Thu, 12 Dec 2024 20:34:06 +0000 Subject: [PATCH 2/2] Completed --- tests/ten/ten_per_005/Input/gnuplot.in | 1 + tests/ten/ten_per_005/run.py | 12 +++++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/ten/ten_per_005/Input/gnuplot.in b/tests/ten/ten_per_005/Input/gnuplot.in index 08298718..83673b7f 100644 --- a/tests/ten/ten_per_005/Input/gnuplot.in +++ b/tests/ten/ten_per_005/Input/gnuplot.in @@ -57,6 +57,7 @@ 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" diff --git a/tests/ten/ten_per_005/run.py b/tests/ten/ten_per_005/run.py index 91b1a2fb..688acdb7 100644 --- a/tests/ten/ten_per_005/run.py +++ b/tests/ten/ten_per_005/run.py @@ -8,7 +8,7 @@ class PySysTest(TenNetworkTest): - ITERATIONS = 128 # iterations per client + ITERATIONS = 1024 # iterations per client CLIENTS = 4 # the number of concurrent clients def __init__(self, descriptor, outsubdir, runner): @@ -60,12 +60,9 @@ def execute(self): # 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(d, OrderedDict()) for d in data] - self.log.info(first_bh) - self.log.info(last_bh) - self.log.info(data_binned_bh) + 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(0, last_bh + 1 - first_bh): + 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)) @@ -124,8 +121,9 @@ def bin_timestamp_data(first, last, data, binned_data): return binned_data @staticmethod - def bin_block_height_data(data, binned_data): + 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 \ No newline at end of file