├── .gitattributes ├── Logs.zip ├── Modules ├── ParityLogParser.js ├── CITALogParser.js ├── CITALogAnalyzer.js ├── ParityLogAnalyzer.js ├── FabricLogAnalyzer.js ├── FabricLogParser.js ├── NetdataParser.js ├── GethLogAnalyzer.js ├── GethLogParser.js └── MetricCalculator.js ├── README.md └── main.js /.gitattributes: -------------------------------------------------------------------------------- 1 | *.zip filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /Logs.zip: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:b3bb044f8380ae8f240d891c351a4987aca9946432145cf1add7e19cbd6d86a3 3 | size 215070381 4 | -------------------------------------------------------------------------------- /Modules/ParityLogParser.js: -------------------------------------------------------------------------------- 1 | // LogParser for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: Log of CITA 5 | // Output: Tuple of 6 | 7 | function parse(line, str) { 8 | var timestamp; 9 | var type; 10 | var action; 11 | var hashOrId; 12 | var info; 13 | 14 | //console.log(str); 15 | 16 | //2018-02-11 01:58:12 Transaction mined (hash cae9c83dbbc92996eec382016b84abf7d8852c299509e7dd81902f265bba050d) 17 |   var regExp = /(.*) Transaction mined \(hash (.*)\)/; 18 | var res = regExp.exec(str); 19 |   if (res!=null) { 20 | //console.log(res[1]); 21 | timestamp = Date.parse(res[1]); 22 | timestamp = parseInt(timestamp/1000); 23 | //console.log(timestamp); 24 | type = "transaction"; 25 | action = "confirmed"; 26 | hashOrId = res[2]; 27 | info = null; 28 | return [line, timestamp, type, action, hashOrId, info]; 29 | } 30 | 31 | 32 | } 33 | 34 | module.exports.parse = parse; -------------------------------------------------------------------------------- /Modules/CITALogParser.js: -------------------------------------------------------------------------------- 1 | // LogParser for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: Log of CITA 5 | // Output: Tuple of 6 | 7 | function parse(line, str) { 8 | var timestamp; 9 | var type; 10 | var action; 11 | var hashOrId; 12 | var info; 13 | 14 | 15 | 16 | //2018-02-08T15:06:12.537214827+08:00 - INFO - BLOCKTXHASHES come height 1036, tx_hashes count is: 821 17 | var regExp = /(.*) - INFO - BLOCKTXHASHES come height (.*), tx_hashes count is: (.*)/ 18 | var res = regExp.exec(str); 19 |   if (res!=null) { 20 | //console.log(res); 21 | timestamp = Date.parse(res[1]); 22 | timestamp = parseInt(timestamp/1000); 23 | type = "block"; 24 | action = "commit"; 25 | hashOrId = +res[2]; 26 | var tx_count = +res[3]; 27 | info = JSON.stringify({tx_count: tx_count}); 28 | return [line, timestamp, type, action, hashOrId, info]; 29 | } 30 | 31 | 32 | } 33 | 34 | module.exports.parse = parse; -------------------------------------------------------------------------------- /Modules/CITALogAnalyzer.js: -------------------------------------------------------------------------------- 1 | // LogAnalyzer for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: 5 | // Tuple of 6 | // starttime(or not): 7 | // endtime(or not): 8 | // 9 | // Output: 10 | // TPS: 11 | // starttime: 12 | // endtime: 13 | 14 | 15 | function analyze(parseresult, starttime=0, endtime=0, verbose=0) { 16 | 17 | var time_defined=false; 18 | 19 | if (starttime!=0 && endtime!=0) 20 | time_defined=true; 21 | else { 22 | starttime = parseresult[0][1]; 23 | endtime = parseresult[parseresult.length-1][1]; 24 | } 25 | 26 | //Transactions Per Second 27 | var txconfirmedcount = 0; 28 | for (var i=0;iendtime)) 31 | continue; 32 | 33 | //console.log(parseresult[i]); 34 | if (parseresult[i][2]=="block") 35 | if (parseresult[i][3]=="commit") 36 | txconfirmedcount += JSON.parse(parseresult[i][5]).tx_count; 37 | } 38 | 39 | var TPS = txconfirmedcount/((endtime-starttime)); 40 | if(verbose) console.log("TPS: ", TPS, txconfirmedcount, (endtime-starttime)); 41 | 42 | return { 43 | TPS: TPS, 44 | starttime: starttime, 45 | endtime: endtime, 46 | txconfirmedcount: txconfirmedcount 47 | } 48 | } 49 | 50 | module.exports.analyze = analyze; -------------------------------------------------------------------------------- /Modules/ParityLogAnalyzer.js: -------------------------------------------------------------------------------- 1 | // LogAnalyzer for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: 5 | // Tuple of 6 | // starttime(or not): 7 | // endtime(or not): 8 | // 9 | // Output: 10 | // TPS: 11 | // starttime: 12 | // endtime: 13 | 14 | 15 | function analyze(parseresult, starttime=0, endtime=0, verbose=0) { 16 | 17 | var time_defined=false; 18 | 19 | if (starttime!=0 && endtime!=0) 20 | time_defined=true; 21 | else { 22 | starttime = parseresult[0][1]; 23 | endtime = parseresult[parseresult.length-1][1]; 24 | } 25 | 26 | //Transactions Per Second 27 | var txconfirmedcount = 0; 28 | for (var i=0;iendtime)) 31 | continue; 32 | 33 | //console.log(parseresult[i]); 34 | //if (parseresult[i][2]=="block") 35 | // if (parseresult[i][3]=="commit") 36 | if (parseresult[i][2]=="transaction") 37 | txconfirmedcount++; 38 | } 39 | 40 | var TPS = txconfirmedcount/((endtime-starttime)); 41 | if(verbose) console.log("TPS: ", TPS, txconfirmedcount, (endtime-starttime)); 42 | 43 | return { 44 | TPS: TPS, 45 | starttime: starttime, 46 | endtime: endtime, 47 | txconfirmedcount: txconfirmedcount 48 | } 49 | } 50 | 51 | module.exports.analyze = analyze; -------------------------------------------------------------------------------- /Modules/FabricLogAnalyzer.js: -------------------------------------------------------------------------------- 1 | // LogAnalyzer for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: 5 | // Tuple of 6 | // starttime(or not): 7 | // endtime(or not): 8 | // 9 | // Output: 10 | // TPS: 11 | // starttime: 12 | // endtime: 13 | 14 | 15 | function analyze(parseresult, starttime=0, endtime=0, verbose=0) { 16 | 17 | var time_defined=false; 18 | 19 | if (starttime!=0 && endtime!=0) 20 | time_defined=true; 21 | else { 22 | starttime = parseresult[0][1]; 23 | endtime = parseresult[parseresult.length-1][1]; 24 | } 25 | 26 | //Transactions Per Second 27 | var txconfirmedcount = 0; 28 | for (var i=0;iendtime)) 31 | continue; 32 | 33 | //console.log(parseresult[i]); 34 | //if (parseresult[i][2]=="block") 35 | // if (parseresult[i][3]=="commit") 36 | if (parseresult[i][5]!=null) 37 | txconfirmedcount += JSON.parse(parseresult[i][5]).tx_count; 38 | } 39 | 40 | var TPS = txconfirmedcount/((endtime-starttime)); 41 | if(verbose) console.log("TPS: ", TPS, txconfirmedcount, (endtime-starttime)); 42 | 43 | return { 44 | TPS: TPS, 45 | starttime: starttime, 46 | endtime: endtime, 47 | txconfirmedcount: txconfirmedcount 48 | } 49 | } 50 | 51 | module.exports.analyze = analyze; -------------------------------------------------------------------------------- /Modules/FabricLogParser.js: -------------------------------------------------------------------------------- 1 | // LogParser for CITA@v0.13 by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: Log of CITA 5 | // Output: Tuple of 6 | 7 | function parse(line, str) { 8 | var timestamp; 9 | var type; 10 | var action; 11 | var hashOrId; 12 | var info; 13 | 14 | 15 | 16 | //0m Committed block with 500 transactions, intended to include 500\r\n","stream":"stdout","time":"2018-02-07T13:45:46.733915168Z"} 17 |   var regExp = /0m Committed block with (.*) transactions, (.*),"time":"(.*)"}/; 18 | var res = regExp.exec(str); 19 |   if (res!=null) { 20 | //console.log(res); 21 | timestamp = Date.parse(res[3]); 22 | timestamp = parseInt(timestamp/1000); 23 | type = "block"; 24 | action = "commit"; 25 | hashOrId = null; 26 | var tx_count = +res[1]; 27 | info = JSON.stringify({tx_count: tx_count}); 28 | return [line, timestamp, type, action, hashOrId, info]; 29 | } 30 | 31 | //0m Committed block 152 with hash f9001cc21abcd792f92bc577f12f1a80d84c8162cf0de9c23df621cd1f10343f6000de889c30dad77d7bb81f91386769990b53bd8d313177446fe6df86d9d78d to chain\r\n","stream":"stdout","time":"2018-02-07T13:45:46.191702162Z"} 32 |   var regExp = /0m Committed block (.*) with hash(.*)"time":"(.*)"}/; 33 | var res = regExp.exec(str); 34 |   if (res!=null) { 35 | //console.log(res); 36 | timestamp = Date.parse(res[3]); 37 | timestamp = parseInt(timestamp/1000); 38 | type = "block"; 39 | action = "commit"; 40 | hashOrId = +res[1]; 41 | info = null; 42 | return [line, timestamp, type, action, hashOrId, info]; 43 | } 44 | 45 | } 46 | 47 | module.exports.parse = parse; -------------------------------------------------------------------------------- /Modules/NetdataParser.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | var http = require("http"); 3 | 4 | function parse(NetdataLog) { 5 | var time_netdata = {}; 6 | 7 | var cpu = fs.readFileSync(NetdataLog+"cpu.json"); 8 | cpu = JSON.parse(cpu).data; 9 | for(i in cpu){ 10 | //if(i>100) break; 11 | if(time_netdata[cpu[i][0]]==null) time_netdata[cpu[i][0]] = {}; 12 | time_netdata[cpu[i][0]]['cpu'] = cpu[i][1]; 13 | } 14 | 15 | var preads = fs.readFileSync(NetdataLog+"preads.json"); 16 | preads = JSON.parse(preads).data; 17 | for(i in preads){ 18 | //if(i>100) break; 19 | if(time_netdata[preads[i][0]]==null) time_netdata[preads[i][0]] = {}; 20 | time_netdata[preads[i][0]]['preads'] = preads[i][1]; 21 | } 22 | 23 | var pwrites = fs.readFileSync(NetdataLog+"pwrites.json"); 24 | pwrites = JSON.parse(pwrites).data; 25 | for(i in pwrites){ 26 | //if(i>100) break; 27 | if(time_netdata[pwrites[i][0]]==null) time_netdata[pwrites[i][0]] = {}; 28 | time_netdata[pwrites[i][0]]['pwrites'] = pwrites[i][1]; 29 | } 30 | 31 | var mem = fs.readFileSync(NetdataLog+"mem.json"); 32 | mem = JSON.parse(mem).data; 33 | for(i in mem){ 34 | //if(i>100) break; 35 | if(time_netdata[mem[i][0]]==null) time_netdata[mem[i][0]] = {}; 36 | time_netdata[mem[i][0]]['mem'] = mem[i][1]; 37 | } 38 | 39 | var vmem = fs.readFileSync(NetdataLog+"vmem.json"); 40 | vmem = JSON.parse(vmem).data; 41 | for(i in vmem){ 42 | //if(i>100) break; 43 | if(time_netdata[vmem[i][0]]==null) time_netdata[vmem[i][0]] = {}; 44 | time_netdata[vmem[i][0]]['vmem'] = vmem[i][1]; 45 | } 46 | 47 | var network = fs.readFileSync(NetdataLog+"network.json"); 48 | network = JSON.parse(network).data; 49 | for(i in network){ 50 | //if(i>100) break; 51 | if(time_netdata[network[i][0]]==null) time_netdata[network[i][0]] = {}; 52 | time_netdata[network[i][0]]['network_received'] = network[i][1]; 53 | time_netdata[network[i][0]]['network_sent'] = network[i][2]; 54 | } 55 | 56 | return time_netdata; 57 | } 58 | 59 | module.exports.parse = parse; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blockchain Performance Monitoring 2 | 3 | This is the source code of the evaluation of the paper "A DETAILED AND REAL-TIME PERFORMANCE MONITORING FRAMEWORK FOR BLOCKCHAIN SYSTEMS". 4 | With one-line command you can replay the evaluation in the paper. 5 | 6 | We decide to move the key back-end code here instead of ibase.site for easier following. 7 | 8 | As for visulization, you can choose any front-end libraries as you like. 9 | 10 | 11 | ## Too Long No Read 12 | 13 | `unzip Logs.zip` (or manually unzip Logs.zip in the directory) 14 | 15 | `node main.js` (if you have installed node.js) 16 | 17 | 18 | ## Qucik Start 19 | 20 | First of all, `git clone https://github.com/tczpl/BlockchainPerformanceMonitoring.git`. 21 | 22 | And `cd BlockchainPerformanceMonitoring`. 23 | 24 | Or download the ZIP, if you have not installed git. 25 | 26 | ### For Linux (Ubuntu 18.04) 27 | 28 | Install unzip: `sudo apt-get install unzip` 29 | 30 | Install nodejs: `sudo apt-get install nodejs` 31 | 32 | Unzip the Logs files: `unzip Logs.zip` 33 | 34 | Just run: `node main.js` 35 | 36 | ### For Windows 37 | Please manually unzip `Logs.zip`. 38 | 39 | Then download and install Node.js from . 40 | 41 | Just run `node main.js` in command. 42 | 43 | ## Paper 44 | If you are interested in this work, you can refer to our paper. 45 | 46 | [Zheng, P., Zheng, Z., Luo, X., Chen, X., & Liu, X. (2018, May). A detailed and real-time performance monitoring framework for blockchain systems. In 2018 IEEE/ACM 40th International Conference on Software Engineering: Software Engineering in Practice Track (pp. 134-143). IEEE.](http://xblock.pro/files/pl/a-detailed-and-real-time-performance-monitoring-framework-for-blockchain-systems.pdf) 47 | 48 | 49 | @inproceedings{zheng2018detailed, 50 | title={A detailed and real-time performance monitoring framework for blockchain systems}, 51 | author={Zheng, Peilin and Zheng, Zibin and Luo, Xiapu and Chen, Xiangping and Liu, Xuanzhe}, 52 | booktitle={2018 IEEE/ACM 40th International Conference on Software Engineering: Software Engineering in Practice Track (ICSE-SEIP)}, 53 | pages={134--143}, 54 | year={2018}, 55 | organization={IEEE} 56 | } 57 | 58 | ## Dependency 59 | We use [Netdata](https://github.com/netdata/netdata) to obtain the data of hardware resource. 60 | 61 | Front-end: [AngularJS](https://angularjs.org/), lately upload. 62 | -------------------------------------------------------------------------------- /Modules/GethLogAnalyzer.js: -------------------------------------------------------------------------------- 1 | // LogAnalyzer for geth@1.5.9-stable-a07539fb by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // In the private chain, the promotion of tx and block is fast. Thus we consider Tx_input is the time when tx is promoting and Tx_confirmed is the time when tx is removed) 4 | // 5 | // Input: Tuple of 6 | // Output: 7 | // TPS: 8 | // ARD: 9 | // PDR: 10 | // RRR: 11 | // TPR: 12 | // CET: 13 | // SUT: 14 | // CCT: 15 | // starttime: 16 | // endtime: 17 | 18 | 19 | 20 | 21 | function analyze(parseresult, starttime=0, endtime=0, verbose=0) { 22 | var time_defined=false; 23 | 24 | if (starttime!=0 && endtime!=0) 25 | time_defined=true; 26 | else { 27 | starttime = parseresult[0][1]; 28 | endtime = parseresult[parseresult.length-1][1]; 29 | } 30 | 31 | //Transactions Per Second 32 | var txconfirmedcount = 0; 33 | for (var i=0;iendtime)) 35 | continue; 36 | 37 | if (parseresult[i][2]=="block") { 38 | if (parseresult[i][3]=="imported") { 39 | txconfirmedcount += JSON.parse(parseresult[i][5]).tx_count; 40 | } 41 | if (parseresult[i][3]=="mined") 42 | for (var j=i; j>=0; --j) 43 | if (parseresult[j][3]=="commit" && parseresult[j][4]==parseresult[i][4]) { 44 | txconfirmedcount += JSON.parse(parseresult[j][5]).tx_count; 45 | break; 46 | } 47 | } 48 | } 49 | var TPS = txconfirmedcount/((endtime-starttime)/1000); 50 | if(verbose) console.log("TPS: ", TPS, txconfirmedcount); 51 | 52 | //Average Response Delay 53 | var txresposecount = 0; 54 | var sumofdelay = 0; 55 | for (var i=0;iendtime)) 57 | continue; 58 | if (parseresult[i][3]=="promoting") 59 | for (var j=i;jendtime)) 77 | continue; 78 | if (parseresult[i][3]=="added") { 79 | if (peers.indexOf(parseresult[i][4])==-1) 80 | peers.push(parseresult[i][4]); 81 | if (maxadded < parseresult[i][1]) 82 | maxadded = parseresult[i][1]; 83 | } 84 | } 85 | 86 | for (var i=0;iendtime)) 88 | continue; 89 | if (parseresult[i][3]=="pong" && minpong > parseresult[i][1]) 90 | minpong = parseresult[i][1]; 91 | } 92 | 93 | var PDR=peers.length/((maxadded-minpong)/1000); 94 | if(verbose) if(verbose) console.log("PDR: ", PDR, peers.length, maxadded, minpong); 95 | 96 | 97 | 98 | 99 | //RPC Response Rate 100 | var respconut = 0; 101 | for (var i=0;iendtime)) 103 | continue; 104 | if (parseresult[i][2]=="rpc" && parseresult[i][3]=="response") 105 | ++respconut; 106 | } 107 | var RRR = respconut/((endtime-starttime)/1000); 108 | if(verbose) console.log("RRR: ", RRR, respconut, endtime, starttime); 109 | 110 | 111 | 112 | //Transaction Propagating Rate 113 | var txprogatingcount = 0; 114 | for (var i=0;iendtime)) 116 | continue; 117 | if (parseresult[i][2]=="transaction" && parseresult[i][3]=="promoting") 118 | ++txprogatingcount; 119 | } 120 | var TPR = txprogatingcount/((endtime-starttime)/1000); 121 | if(verbose) console.log("TPR: ", TPR, txprogatingcount, endtime,starttime); 122 | 123 | 124 | //Contract Execution Time 125 | var exetimes = 0; 126 | var sumofexetime = 0; 127 | var temptime = 0; 128 | for (var i=0;iendtime)) 130 | continue; 131 | if (parseresult[i][2]=="execution" && parseresult[i][3]=="start") { 132 | temptime = parseresult[i][1]; 133 | continue; 134 | } 135 | if (parseresult[i][2]=="execution" && parseresult[i][3]=="done" &&temptime!=0) { 136 | ++exetimes; 137 | sumofexetime += parseresult[i][1]-temptime; 138 | temptime = 0; 139 | } 140 | } 141 | var CET = sumofexetime/1000/exetimes; 142 | if(verbose) console.log("CET: ", CET, sumofexetime, exetimes); 143 | 144 | 145 | 146 | //State Updating Time 147 | var uptimes = 0; 148 | var sumofuptime = 0; 149 | var temptime = 0; 150 | for (var i=0;iendtime)) 152 | continue; 153 | if (parseresult[i][2]=="execution" && parseresult[i][3]=="done") { 154 | temptime = parseresult[i][1]; 155 | continue; 156 | } 157 | if (parseresult[i][2]=="state" && parseresult[i][3]=="done" &&temptime!=0) { 158 | ++uptimes; 159 | sumofuptime += parseresult[i][1]-temptime; 160 | temptime = 0; 161 | } 162 | } 163 | var SUT = sumofuptime/1000/uptimes; 164 | if(verbose) console.log ("SUT: ", SUT, sumofuptime, uptimes); 165 | 166 | 167 | //Consensus-Cost Time 168 | var txcount = 0; 169 | var sumofcctime = 0; 170 | var temptime = 0; 171 | var wantblock = 0; 172 | var wanttx = 0; 173 | for (var i=0;iendtime)) 175 | continue; 176 | if (parseresult[i][2]=="block" && parseresult[i][3]=="commit" && parseresult[i][4]>=wantblock) { 177 | temptime = parseresult[i][1]; 178 | wantblock = parseresult[i][4]; 179 | wanttx = JSON.parse(parseresult[i][5]).tx_count; 180 | continue; 181 | } 182 | if (parseresult[i][2]=="block" && parseresult[i][3]=="mined" && parseresult[i][4]==wantblock) { 183 | ++wantblock; 184 | sumofcctime += (parseresult[i][1]-temptime)*wanttx; 185 | txcount += wanttx; 186 | temptime = 0; 187 | } 188 | } 189 | var CCT = sumofcctime/1000/txcount; 190 | if(verbose) console.log("CCT: ", CCT, sumofcctime, txcount); 191 | 192 | return { 193 | TPS: TPS, 194 | ARD: ARD, 195 | PDR: PDR, 196 | RRR: RRR, 197 | TPR: TPR, 198 | CET: CET, 199 | SUT: SUT, 200 | CCT: CCT, 201 | starttime: parseInt(starttime/1000), 202 | endtime: parseInt(endtime/1000), 203 | txconfirmedcount: txconfirmedcount 204 | } 205 | } 206 | 207 | module.exports.analyze = analyze; -------------------------------------------------------------------------------- /Modules/GethLogParser.js: -------------------------------------------------------------------------------- 1 | // LogParser for geth@1.5.9-stable-a07539fb by (zhengpl3@mail2.sysu.edu.cn, QQ/Wechat:326486019) 2 | // Different versions might output the log in differet formats. 3 | // 4 | // Input: Log of Geth 5 | // Output: Tuple of 6 | 7 | 8 | var CONST_YEAR = 2018; 9 | 10 | 11 | function parse(line, str) { 12 | var timestamp; 13 | var type; 14 | var action; 15 | var hashOrId; 16 | var info; 17 | 18 | 19 | //I0907 02:27:27.564393 internal/ethapi/api.go:1143] Tx(0xd07e8fb644bf661602f292f70899c2706a465e7480c5244238af19d9daab2cee) to: 0xaae260314e3cb5023200da699177bc827db1b982 20 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) internal\/ethapi\/api.go:1143] Tx\((.*)\) to:(.*)/; 21 |   var res = regExp.exec(str); 22 |   if (res!=null) { 23 | //console.log(res); 24 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 25 | type = "transaction"; 26 | action = "firstin"; 27 | hashOrId = res[4]; 28 | info = "toac: "+res[5]; 29 | return [line, timestamp, type, action, hashOrId, info]; 30 | } 31 | 32 | //I0907 02:21:05.677381 internal/ethapi/api.go:1141] Tx(0x288ce4254ce6ee88a554da8acff59a1f9f02913639fd5b6d2aec36f2c3d1225a) created: 0x2a8ab576204725807b7bae4ac43e8bd31b336a2f 33 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) internal\/ethapi\/api.go:1141] Tx\((.*)\) created:(.*)/; 34 |   var res = regExp.exec(str); 35 |   if (res!=null) { 36 | //console.log(res); 37 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 38 | type = "transaction"; 39 | action = "firstin"; 40 | hashOrId = res[4]; 41 | info = "createdac: "+res[5]; 42 | return [line, timestamp, type, action, hashOrId, info]; 43 | } 44 | 45 | //I0907 02:24:54.032288 core/blockchain.go:1070] imported 3 blocks, 3 txs (262.503 Mg) in 917.112ms (286.228 Mg/s). #87 [52dab1cb… / b5cf2a7c…] 46 |   var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/blockchain.go:1070] imported (.*) blocks, (.*) txs (.*) #(.*)\[/; 47 |   var res = regExp.exec(str); 48 |   if (res!=null) { 49 | //console.log(res); 50 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 51 | type = "block"; 52 | action = "imported"; 53 | hashOrId = +res[7]; 54 | var block_count = +res[4]; 55 | var tx_count = +res[5]; 56 | info = JSON.stringify({block_count:block_count, tx_count: tx_count}); 57 | return [line, timestamp, type, action, hashOrId, info]; 58 | } 59 | 60 | //I0907 02:27:28.567969 miner/worker.go:517] commit new work on block 101 with 1 txs & 0 uncles. Took 8.380564ms 61 |   var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) miner\/worker.go:517] commit new work on block(.*)with(.*)txs/; 62 | var res = regExp.exec(str); 63 | if (res!=null) { 64 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 65 | type = "block"; 66 | action = "commit"; 67 | hashOrId = +res[4]; 68 | var tx_count = +res[5]; 69 | info = JSON.stringify({tx_count: tx_count}); 70 | return [line, timestamp, type, action, hashOrId, info]; 71 | } 72 | 73 | 74 | //I0907 02:27:29.122591 miner/unconfirmed.go:83] 🔨 mined potential block #101 [88049f4b…], waiting for 5 blocks to confirm 75 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) miner\/unconfirmed.go:83] 🔨 mined potential block #(.*) \[/; 76 |   var res = regExp.exec(str); 77 |   if (res!=null) { 78 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 79 | type = "block"; 80 | action = "mined"; 81 | hashOrId = +res[4]; 82 | info = null; 83 | return [line, timestamp, type, action, hashOrId, info]; 84 | } 85 | 86 | //Tx confirmed 87 | //In the private chain, the promotion of tx and block is fast. Thus we consider Tx_input is the time when tx is promoting and Tx_confirmed is the time when tx is removed) 88 | 89 | //I0907 02:24:35.714632 p2p/discover/udp.go:467] >>> 212.32.240.214:30303 discover.ping 90 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) p2p\/discover\/udp.go:467] >>> (.*) discover.ping/; 91 |   var res = regExp.exec(str); 92 |   if (res!=null) { 93 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 94 | type = "peer"; 95 | action = "pong"; 96 | hashOrId = res[4]; 97 | info = "discover.ping"; 98 | return [line, timestamp, type, action, hashOrId, info]; 99 | } 100 | 101 | //I0907 02:24:44.096555 p2p/server.go:470] new task: static dial 3f76f50037e9ddf4 192.168.152.129:30303 102 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) p2p\/server.go:470] new task: static dial (.*) (.*)/; 103 |   var res = regExp.exec(str); 104 |   if (res!=null) { 105 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 106 | type = "peer"; 107 | action = "pong"; 108 | hashOrId = res[5]; 109 | info = "static"; 110 | return [line, timestamp, type, action, hashOrId, info]; 111 | } 112 | 113 | 114 | 115 | //I0907 02:24:40.342887 p2p/server.go:737] Added Peer 6fd97488cc58e0af 212.32.240.214:30303 116 | //I0907 02:24:44.100567 p2p/server.go:737] Added Peer 3f76f50037e9ddf4 192.168.152.129:30303 117 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) p2p\/server.go:737] Added Peer (.*) (.*)/; 118 |   var res = regExp.exec(str); 119 |   if (res!=null) { 120 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 121 | type = "peer"; 122 | action = "added"; 123 | hashOrId = res[5]; 124 | info = null; 125 | return [line, timestamp, type, action, hashOrId, info]; 126 | } 127 | 128 | //I0907 02:21:03.520078 rpc/client.go:505] <-readResp: response {"jsonrpc":"2.0","id":40,"result":true} 129 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) rpc\/client.go:505] <-readResp: response (.*)/; 130 |   var res = regExp.exec(str); 131 |   if (res!=null) { 132 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 133 | type = "rpc"; 134 | action = "response"; 135 | hashOrId = null; 136 | info = res[4]; 137 | return [line, timestamp, type, action, hashOrId, info]; 138 | } 139 | 140 | 141 | //I0907 02:27:28.702213 core/tx_pool.go:534] Promoting queued transaction: 142 | //TX(390e101b7670e86abf03eda9ca48b1d451f03fe2707f8d7c72c7eeedde9ac6a5) 143 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/tx_pool.go:534] Promoting queued transaction: /; 144 |   var res = regExp.exec(str); 145 |   if (res!=null) { 146 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 147 | type = "transaction"; 148 | action = "promoting"; 149 | hashOrId = null; 150 | info = null; 151 | return [line, timestamp, type, action, hashOrId, info]; 152 | } 153 | var regExp = /TX\((.*)\)/; 154 |   var res = regExp.exec(str); 155 |   if (res!=null) { 156 | timestamp = null; 157 | type = null; 158 | action = null; 159 | hashOrId = res[1]; 160 | info = null; 161 | return [line, timestamp, type, action, hashOrId, info]; 162 | } 163 | 164 | 165 | 166 | //I0907 02:21:05.681136 core/vm/vm.go:121] evm running: 69b37e7d 167 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/vm\/vm.go:121] evm running: (.*)/; 168 |   var res = regExp.exec(str); 169 |   if (res!=null) { 170 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 171 | type = "execution"; 172 | action = "start"; 173 | hashOrId = null; 174 | info = res[4]; 175 | return [line, timestamp, type, action, hashOrId, info]; 176 | } 177 | 178 | 179 | //I0907 02:30:15.323768 core/vm/vm.go:124] evm done: 7c9c3758. time: 7.712515322s 180 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/vm\/vm.go:124] evm done: (.*). time: (.*)/; 181 |   var res = regExp.exec(str); 182 |   if (res!=null) { 183 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 184 | type = "execution"; 185 | action = "done"; 186 | hashOrId = null; 187 | info = res[4]; 188 | return [line, timestamp, type, action, hashOrId, info]; 189 | } 190 | 191 | 192 | //I0907 02:30:15.324279 core/state_processor.go:125] receipt{med=c96bcb25ae930bfcbba71f4e01bd4c44868a90dbec21366c606f4187c9603f58 cgas=229041126 bloom=00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 logs=[]} 193 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/state_processor.go:125] receipt(.*)/; 194 |   var res = regExp.exec(str); 195 |   if (res!=null) { 196 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 197 | type = "state"; 198 | action = "done"; 199 | hashOrId = null; 200 | info = res[4]; 201 | return [line, timestamp, type, action, hashOrId, info]; 202 | } 203 | 204 | 205 | //I0907 02:27:29.549264 core/tx_pool.go:655] Removed old pending transaction: 206 | //TX(d07e8fb644bf661602f292f70899c2706a465e7480c5244238af19d9daab2cee) 207 | var regExp = /I([0-9][0-9])([0-9][0-9]) (.*) core\/tx_pool.go:655] Removed old pending transaction:/; 208 |   var res = regExp.exec(str); 209 |   if (res!=null) { 210 | timestamp = new Date(CONST_YEAR+'-'+res[1]+'-'+res[2]+' '+res[3]).getTime(); 211 | type = "transaction"; 212 | action = "removed"; 213 | hashOrId = null; 214 | info = null; 215 | return [line, timestamp, type, action, hashOrId, info]; 216 | } 217 | var regExp = /TX\((.*)\)/; 218 |   var res = regExp.exec(str); 219 |   if (res!=null) { 220 | timestamp = null; 221 | type = null; 222 | action = null; 223 | hashOrId = res[1]; 224 | info = null; 225 | return [line, timestamp, type, action, hashOrId, info]; 226 | } 227 | 228 | 229 | 230 | } 231 | 232 | module.exports.parse = parse; -------------------------------------------------------------------------------- /Modules/MetricCalculator.js: -------------------------------------------------------------------------------- 1 | // Input: Validating Log, Synchronize Log(if needed), Netdata Log 2 | // Output: Metric 3 | 4 | var fs = require('fs'); 5 | 6 | var GethLogParser = require('./GethLogParser'); 7 | var GethLogAnalyzer = require('./GethLogAnalyzer'); 8 | var CITALogParser = require('./CITALogParser'); 9 | var CITALogAnalyzer = require('./CITALogAnalyzer'); 10 | 11 | var FabricLogParser = require('./FabricLogParser'); 12 | var FabricLogAnalyzer = require('./FabricLogAnalyzer'); 13 | var ParityLogParser = require('./ParityLogParser'); 14 | var ParityLogAnalyzer = require('./ParityLogAnalyzer'); 15 | 16 | var NetdataParser = require('./NetdataParser'); 17 | var F = 3.6;// GHz 18 | 19 | 20 | function GethCalculate(ValidatingLog, NetdataLog, starttime, endtime) { 21 | var data = fs.readFileSync(ValidatingLog, {flag: 'r+', encoding: 'utf8'}); 22 | //Parse 23 | var parseResult=[]; 24 | var dataToRow= data.split('\n'); 25 | var tuple; 26 | var rows = 0; 27 | var outputToFile=""; 28 | 29 | for (var i=rows;i=kaishi && jiexi[j][0]PDRmax) 295 | PDRmax = timeWindowResult.PDR; 296 | if (timeWindowResult.TPR>TPRmax) 297 | TPRmax = timeWindowResult.TPR; 298 | } 299 | } 300 | console.log({ 301 | PDRmax: PDRmax, 302 | TPRmax: TPRmax 303 | }); 304 | 305 | var duration = 1; 306 | console.log("Pri-2-MAX") 307 | var PDRmax = 0; 308 | var TPRmax = 0; 309 | for (var i=4;i<6;++i) { 310 | var res = GethCalculate(GethValidatingLog[i],GethNetdataLog[i], Gethperiod[i][0]*1000, Gethperiod[i][1]*1000); 311 | for (var timeWindow = res.starttime; timeWindowPDRmax) 314 | PDRmax = timeWindowResult.PDR; 315 | if (timeWindowResult.TPR>TPRmax) 316 | TPRmax = timeWindowResult.TPR; 317 | } 318 | } 319 | console.log({ 320 | PDRmax: PDRmax, 321 | TPRmax: TPRmax 322 | }); 323 | 324 | 325 | var duration = 1; 326 | console.log("Pri-1-MAX") 327 | var PDRmax = 0; 328 | var TPRmax = 0; 329 | for (var i=6;i<7;++i) { 330 | var res = GethCalculate(GethValidatingLog[i],GethNetdataLog[i], Gethperiod[i][0]*1000, Gethperiod[i][1]*1000); 331 | for (var timeWindow = res.starttime; timeWindowPDRmax) 334 | PDRmax = timeWindowResult.PDR; 335 | } 336 | } 337 | console.log({ 338 | PDRmax: PDRmax 339 | }); 340 | 341 | var duration = 60; 342 | console.log("Pub-1-MAX") 343 | var PDRmax = 0; 344 | var TPRmax = 0; 345 | for (var i=7;i<8;++i) { 346 | var res = GethCalculate(GethValidatingLog[i],GethNetdataLog[i], Gethperiod[i][0]*1000, Gethperiod[i][1]*1000); 347 | for (var timeWindow = res.starttime; timeWindowPDRmax) 350 | PDRmax = timeWindowResult.PDR; 351 | } 352 | } 353 | console.log({ 354 | PDRmax: PDRmax 355 | }); 356 | 357 | 358 | } 359 | 360 | 361 | console.log("======Q1_overhead======"); 362 | Q1_overhead_tps(); 363 | console.log("\n======Q2_platforms======"); 364 | Q2_overall_platforms(); 365 | console.log("\n======Q2_contracts======"); 366 | Q2_overall_contracts(); 367 | console.log("\n======Q3_detailed_MAX======"); 368 | Q3_detailed_MAX(); 369 | console.log("\n======Q3_detailed======"); 370 | Q3_detailed(); 371 | --------------------------------------------------------------------------------