-
Notifications
You must be signed in to change notification settings - Fork 244
[rlp] Add no_std support #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
ecea884
bfca031
17a5a21
bb76515
89a6be2
a137df0
1ce5187
822933d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,11 +14,8 @@ | |
|
|
||
| #![feature(test)] | ||
|
|
||
| extern crate ethereum_types; | ||
| extern crate rlp; | ||
| extern crate test; | ||
|
|
||
| use ethereum_types::U256; | ||
| use rlp::{RlpStream, Rlp}; | ||
| use test::Bencher; | ||
|
|
||
|
|
@@ -42,29 +39,6 @@ fn bench_decode_u64_value(b: &mut Bencher) { | |
| }); | ||
| } | ||
|
|
||
| #[bench] | ||
| fn bench_stream_u256_value(b: &mut Bencher) { | ||
| b.iter(|| { | ||
| // u256 | ||
| let mut stream = RlpStream::new(); | ||
| let uint: U256 = "8090a0b0c0d0e0f00910203040506077000000000000000100000000000012f0".into(); | ||
| stream.append(&uint); | ||
| let _ = stream.out(); | ||
| }); | ||
| } | ||
|
|
||
| #[bench] | ||
| fn bench_decode_u256_value(b: &mut Bencher) { | ||
| b.iter(|| { | ||
| // u256 | ||
| let data = vec![0xa0, 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0, 0x09, 0x10, 0x20, | ||
| 0x30, 0x40, 0x50, 0x60, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
| 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0xf0]; | ||
| let rlp = Rlp::new(&data); | ||
| let _ : U256 = rlp.as_val().unwrap(); | ||
| }); | ||
| } | ||
|
|
||
| #[bench] | ||
| fn bench_stream_nested_empty_lists(b: &mut Bencher) { | ||
| b.iter(|| { | ||
|
|
@@ -106,13 +80,13 @@ fn bench_stream_1000_empty_lists(b: &mut Bencher) { | |
| fn bench_decode_1000_values(b: &mut Bencher) { | ||
| let mut stream = RlpStream::new_list(1000); | ||
| for _ in 0..1000 { | ||
| stream.append(&U256::from(1)); | ||
| stream.append(&1u64); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the amount of data tested, making it impossible to compare tests before/after this change. In general I'm not sure why the dev dependencies can't depend on
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the same data length as before here. |
||
| } | ||
| let data= stream.out(); | ||
| b.iter(|| { | ||
| let rlp = Rlp::new(&data); | ||
| for i in 0..1000 { | ||
| let _: U256 = rlp.val_at(i).unwrap(); | ||
| let _: u64 = rlp.val_at(i).unwrap(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use the same data length as before here. |
||
| } | ||
| }); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why prefer
rustc-hextohex-literal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
rustc-hexis enough to encode/decode hex. There is no need to introduce more dependencies, even if it is justdev-dependencies.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests need to be as readable as possible, which is why I think
hex-literalis better.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(The new
0.2ofhex-literalis edition compatible too!)