reader buf 100M => 4K

This commit is contained in:
Dmitry Belyaev 2022-10-07 16:09:44 +03:00
parent 16784a3319
commit 7ee0b62ed7
Signed by: b4tman
GPG Key ID: 41A00BF15EA7E5F3
2 changed files with 11 additions and 11 deletions

View File

@ -6,18 +6,18 @@
hyperfine -n print -n print2 -n zip-print -w 100 -m 100 ".\target\release\chgk_ledb.exe print 444" ".\target\release\chgk_ledb.exe print2 444" ".\target\release\chgk_ledb.exe zip-print 4 84"
Benchmark 1: print
Time (mean ± σ): 17.7 ms ± 2.0 ms [User: 4.3 ms, System: 13.3 ms]
Range (min … max): 15.7 ms … 32.0 ms 100 runs
Time (mean ± σ): 16.9 ms ± 5.0 ms [User: 5.5 ms, System: 13.4 ms]
Range (min … max): 14.5 ms … 65.1 ms 107 runs
Benchmark 2: print2
Time (mean ± σ): 62.2 ms ± 4.3 ms [User: 5.6 ms, System: 53.1 ms]
Range (min … max): 58.1 ms … 94.5 ms 100 runs
Time (mean ± σ): 16.4 ms ± 5.2 ms [User: 4.9 ms, System: 13.2 ms]
Range (min … max): 13.9 ms … 67.5 ms 110 runs
Benchmark 3: zip-print
Time (mean ± σ): 37.0 ms ± 6.1 ms [User: 12.0 ms, System: 20.8 ms]
Range (min … max): 32.3 ms … 94.3 ms 100 runs
Time (mean ± σ): 38.3 ms ± 7.4 ms [User: 13.5 ms, System: 22.1 ms]
Range (min … max): 32.8 ms … 91.7 ms 100 runs
Summary
'print' ran
2.08 ± 0.41 times faster than 'zip-print'
3.50 ± 0.46 times faster than 'print2'
'print2' ran
1.04 ± 0.45 times faster than 'print'
2.35 ± 0.87 times faster than 'zip-print'

View File

@ -238,7 +238,7 @@ fn read_from_db2(id: u32) -> Option<Question> {
let cfg = bincode::config::standard();
let input = fs::File::open("test.bin").expect("open input");
let mut input = std::io::BufReader::with_capacity(100 * 1024 * 1024, input);
let mut input = std::io::BufReader::with_capacity(4 * 1024, input);
let mut len_data: [u8; LEN_SIZE] = [0; LEN_SIZE];
input.read_exact(&mut len_data).expect("read len");
@ -273,7 +273,7 @@ fn read_from_db2(id: u32) -> Option<Question> {
.read_exact(&mut pos_curr_data)
.expect("read current pos");
input.read_exact(&mut pos_next_data).expect("read next pos");
let data_pos = u32::from_le_bytes(pos_curr_data);
let data_pos_next = u32::from_le_bytes(pos_next_data);
let data_len = data_pos_next - data_pos;