diff --git a/rollup/circuitcapacitychecker/impl_test.go b/rollup/circuitcapacitychecker/impl_test.go new file mode 100644 index 0000000000..ccba5a4145 --- /dev/null +++ b/rollup/circuitcapacitychecker/impl_test.go @@ -0,0 +1,47 @@ +package circuitcapacitychecker + +import ( + "encoding/json" + "os" + "path/filepath" + "testing" + + "github.com/scroll-tech/go-ethereum/core/types" +) + +type traceContainer struct { + Jsonrpc string + Id int + Result *types.BlockTrace +} + +func BenchmarkApplyBlock(b *testing.B) { + ccc := NewCircuitCapacityChecker(false) + + dir, err := os.ReadDir("block-traces") + if err != nil { + b.Fatal(err) + } + + for _, bte := range dir { + next := filepath.Join("block-traces", bte.Name()) + data, err := os.ReadFile(next) + if err != nil { + b.Fatal(err) + } + + var container traceContainer + err = json.Unmarshal(data, &container) + if err != nil { + b.Fatal(err) + } + + b.Run(bte.Name(), func(b *testing.B) { + ccc.Reset() + _, err := ccc.ApplyBlock(container.Result) + if err != nil { + b.Fatal(err) + } + }) + } +}