File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed
Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -673,7 +673,8 @@ type storedReceiptRLP struct {
673673}
674674
675675// ReceiptLogs is a barebone version of ReceiptForStorage which only keeps
676- // the list of logs.
676+ // the list of logs. When decoding a stored receipt into this object we
677+ // avoid creating the bloom filter.
677678type receiptLogs struct {
678679 Logs []* types.Log
679680}
Original file line number Diff line number Diff line change @@ -857,3 +857,29 @@ func TestDeriveLogFields(t *testing.T) {
857857 }
858858 }
859859}
860+
861+ func BenchmarkDecodeRLPLogs (b * testing.B ) {
862+ // Encoded receipts from block 0x14ee094309fbe8f70b65f45ebcc08fb33f126942d97464aad5eb91cfd1e2d269
863+ buf , err := ioutil .ReadFile ("testdata/stored_receipts.bin" )
864+ if err != nil {
865+ b .Fatal (err )
866+ }
867+ b .Run ("ReceiptForStorage" , func (b * testing.B ) {
868+ b .ReportAllocs ()
869+ var r []* types.ReceiptForStorage
870+ for i := 0 ; i < b .N ; i ++ {
871+ if err := rlp .DecodeBytes (buf , & r ); err != nil {
872+ b .Fatal (err )
873+ }
874+ }
875+ })
876+ b .Run ("rlpLogs" , func (b * testing.B ) {
877+ b .ReportAllocs ()
878+ var r []* receiptLogs
879+ for i := 0 ; i < b .N ; i ++ {
880+ if err := rlp .DecodeBytes (buf , & r ); err != nil {
881+ b .Fatal (err )
882+ }
883+ }
884+ })
885+ }
You can’t perform that action at this time.
0 commit comments