Add aggregate number, add number of bytes for storage calls

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-06-11 22:25:24 +02:00
parent c90d35869b
commit 071ddf6563
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA
2 changed files with 25 additions and 3 deletions

View File

@ -108,12 +108,12 @@ func (pl *pricelistV0) OnMethodInvocation(value abi.TokenAmount, methodNum abi.M
// OnIpldGet returns the gas used for storing an object
func (pl *pricelistV0) OnIpldGet(dataSize int) GasCharge {
return newGasCharge("OnIpldGet", pl.ipldGetBase+int64(dataSize)*pl.ipldGetPerByte, 0)
return newGasCharge(fmt.Sprintf("OnIpldGet:%db", dataSize), pl.ipldGetBase+int64(dataSize)*pl.ipldGetPerByte, 0)
}
// OnIpldPut returns the gas used for storing an object
func (pl *pricelistV0) OnIpldPut(dataSize int) GasCharge {
return newGasCharge("OnIpldPut", pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte)
return newGasCharge(fmt.Sprintf("OnIpldPut:%db", dataSize), pl.ipldPutBase, int64(dataSize)*pl.ipldPutPerByte)
}
// OnCreateActor returns the gas used for creating an actor

View File

@ -975,7 +975,11 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
}
.slow-true-false { color: #660; }
.slow-true-true { color: #f80; }
table { font-size: 12px; }
table {
font-size: 12px;
border-collapse: collapse;
}
tr.sum { border-top: 1px solid black; }
</style>
</head>
<body>
@ -1029,10 +1033,20 @@ func computeStateHtml(ts *types.TipSet, o *api.ComputeStateOutput, getCode func(
}
fmt.Printf("\n<details><summary>Gas Trace</summary><table><tr>" +
"<th>Name</th><th>Total/Compute/Storage</th><th>Time Taken</th><th>Location</th></tr>")
var sumTotal, sumCompute, sumStorage int64
var sumTime time.Duration
for _, gc := range ir.ExecutionTrace.GasCharges {
fmt.Printf("<tr><td>%s</td><td>%d/%d/%d</td><td>%s</td><td>%s</td></tr>",
gc.Name, gc.TotalGas, gc.ComputeGas, gc.StorageGas, gc.TimeTaken, gc.Location)
sumTotal += gc.TotalGas
sumCompute += gc.ComputeGas
sumStorage += gc.StorageGas
sumTime += gc.TimeTaken
}
fmt.Printf("<tr class=\"sum\"><td>%s</td><td>%d/%d/%d</td><td>%s</td><td>%s</td></tr>",
"<b>Sum</b>", sumTotal, sumCompute, sumStorage, sumTime, "")
fmt.Printf("</table></details>\n")
fmt.Println("<div>Execution trace:</div>")
@ -1092,10 +1106,18 @@ func printInternalExecutionsHtml(hashName string, trace []types.ExecutionTrace,
}
fmt.Printf("\n<details><summary>Gas Trace</summary><table><tr>" +
"<th>Name</th><th>Total/Compute/Storage</th><th>Time Taken</th><th>Location</th></tr>")
var sumTotal, sumCompute, sumStorage int64
var sumTime time.Duration
for _, gc := range im.GasCharges {
fmt.Printf("<tr><td>%s</td><td>%d/%d/%d</td><td>%s</td><td>%s</td></tr>",
gc.Name, gc.TotalGas, gc.ComputeGas, gc.StorageGas, gc.TimeTaken, gc.Location)
sumTotal += gc.TotalGas
sumCompute += gc.ComputeGas
sumStorage += gc.StorageGas
sumTime += gc.TimeTaken
}
fmt.Printf("<tr class=\"sum\"><td>%s</td><td>%d/%d/%d</td><td>%s</td><td>%s</td></tr>",
"<b>Sum</b>", sumTotal, sumCompute, sumStorage, sumTime, "")
fmt.Printf("</table></details>\n")
if len(im.Subcalls) > 0 {
fmt.Println("<div>Subcalls:</div>")