Log Analysis and Visulization

In [1]:
import utils
import os
from os import path
import datetime
import pandas as pd

Result

  • Statistics Summary
    • transaction per second
    • time per block
    • size
    • gas
  • Features vs Time / Block Height (with all shards / per shard)
    • staking transaction per second
    • total transaction per second
    • transaction per second
    • time per block
    • size
    • gas
In [2]:
if __name__ == "__main__":
    
    date = datetime.date.today()-datetime.timedelta(days=1)
    name = "mainnet_"+date.strftime("%Y_%m_%d")+".log"
    fig_dir = "../../graphs/test_logs/mainnet/" + date.strftime("%Y_%m_%d") + "/"
    log_dir = "/home/ubuntu/jupyter/monitor/mini_explorer/data/" + name
    html_dir = "../../docs/graphs/test_logs/mainnet/" + date.strftime("%Y_%m_%d") + "/"

    data = [html_dir, fig_dir]
    for directory in data:
        if not path.exists(directory):
            try:
                os.makedirs(directory)
            except:
                print("Could not make directory")
                exit(1)

    data = utils.read_data(log_dir)
    shard = utils.data_processing(data)
    
    utils.set_config({
        'ignore_printing_statistics_summary': False,
        'ignore_drawing_features_vs_time_per_shard' : True,
        'ignore_drawing_features_vs_block_per_shard' : True,
        'ignore_drawing_staking_features_vs_time_per_shard' : True,
        'ignore_drawing_staking_features_vs_block_per_shard' : True,
        'ignore_drawing_features_vs_time' : False,
        'ignore_drawing_features_vs_block' : True
    })
    
    config = utils.config
    ## get the index of the new chain started
    index = []
    for s in shard:
        i = s[s['time_per_block'] < 0].index.tolist()   
        if len(i) == 0:
            break
        i.insert(0,0)
        i.append(len(s))
        index.append(i)
    
    if len(index) == 0:
        new = pd.concat(shard)
        new.reset_index(inplace = True, drop = True)
        print("transaction for ", date, new['transactions'].sum())
        utils.visualization(new, fig_dir, html_dir, config)
    else:    
        for i in range(len(index[0])-1):
            df = []
            for s in range(len(shard)):
                df.append(shard[s].iloc[index[s][i]+1:index[s][i+1]])
            new = pd.concat(df)

            fig_path = fig_dir + "chain_" + str(i) + "/"
            if not os.path.exists(fig_path):
                os.makedirs(fig_path)

            utils.visualization(new, fig_path, html_dir, config)
transaction for  2020-04-29 720
Statistics summary for shard 0
==================================
Total data points: 10500
              size           gas  transaction_per_second  time_per_block
mean    753.772952   1420.000000                0.008246        8.228286
std     704.522449   5723.872837                0.033363        0.423812
min     738.000000      0.000000                0.000000        8.000000
25%     738.000000      0.000000                0.000000        8.000000
50%     738.000000      0.000000                0.000000        8.000000
75%     738.000000      0.000000                0.000000        8.000000
max   72777.000000  63000.000000                0.375000       12.000000

Statistics summary for shard 1
==================================
Total data points: 10577
            size           gas  transaction_per_second  time_per_block
mean  738.054269      9.927201                0.000059        8.168290
std     2.495776    456.500125                0.002717        0.374141
min   738.000000      0.000000                0.000000        8.000000
25%   738.000000      0.000000                0.000000        8.000000
50%   738.000000      0.000000                0.000000        8.000000
75%   738.000000      0.000000                0.000000        8.000000
max   855.000000  21000.000000                0.125000        9.000000

Statistics summary for shard 2
==================================
Total data points: 10511
              size           gas  transaction_per_second  time_per_block
mean    744.886500      5.993721                0.000034        8.219389
std     702.663055    354.745241                0.002036        0.413852
min     738.000000      0.000000                0.000000        8.000000
25%     738.000000      0.000000                0.000000        8.000000
50%     738.000000      0.000000                0.000000        8.000000
75%     738.000000      0.000000                0.000000        8.000000
max   72777.000000  21000.000000                0.125000        9.000000

Statistics summary for shard 3
==================================
Total data points: 10570
            size           gas  transaction_per_second  time_per_block
mean  738.021760      3.973510                0.000024        8.174172
std     1.581812    288.852581                0.001719        0.379275
min   738.000000      0.000000                0.000000        8.000000
25%   738.000000      0.000000                0.000000        8.000000
50%   738.000000      0.000000                0.000000        8.000000
75%   738.000000      0.000000                0.000000        8.000000
max   853.000000  21000.000000                0.125000        9.000000

Features vs Time
PNG saved in ../../graphs/test_logs/mainnet/2020_04_29/
==================================
HTML saved in 
HTML saved in 
HTML saved in 
HTML saved in