From 74c2ba149c346b40b4256c43973230f5cd556213 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Mon, 14 Jul 2025 16:23:29 +0200 Subject: [PATCH 1/2] test: add benchmarks with principal --- benchmarks/btreemap/canbench_results.yml | 462 ++++++++++++++--------- benchmarks/btreemap/src/main.rs | 33 ++ benchmarks/src/random.rs | 16 + 3 files changed, 343 insertions(+), 168 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index 549b19e1..b0905770 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -41,6 +41,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_contains_blob_32_0: + total: + calls: 1 + instructions: 329571719 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_contains_blob_32_1024: total: calls: 1 @@ -132,6 +139,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_contains_principal: + total: + calls: 1 + instructions: 343900374 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_contains_u64_blob8: total: calls: 1 @@ -188,6 +202,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_contains_vec_32_0: + total: + calls: 1 + instructions: 355321635 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_contains_vec_32_1024: total: calls: 1 @@ -321,6 +342,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_get_blob_32_0: + total: + calls: 1 + instructions: 337429950 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_get_blob_32_1024: total: calls: 1 @@ -412,6 +440,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_get_principal: + total: + calls: 1 + instructions: 351261213 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_get_u64_blob8: total: calls: 1 @@ -468,6 +503,13 @@ benches: heap_increase: 0 stable_memory_increase: 0 scopes: {} + btreemap_v2_get_vec_32_0: + total: + calls: 1 + instructions: 358216658 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} btreemap_v2_get_vec_32_1024: total: calls: 1 @@ -562,280 +604,301 @@ benches: btreemap_v2_insert_10mib_values: total: calls: 1 - instructions: 4388592719 + instructions: 4387226354 heap_increase: 161 stable_memory_increase: 3613 scopes: {} btreemap_v2_insert_blob8_u64: total: calls: 1 - instructions: 436633391 + instructions: 436629416 heap_increase: 0 stable_memory_increase: 4 scopes: {} btreemap_v2_insert_blob_1024_128: total: calls: 1 - instructions: 5496222167 + instructions: 5496218165 heap_increase: 0 stable_memory_increase: 196 scopes: {} btreemap_v2_insert_blob_128_128: total: calls: 1 - instructions: 1180838234 + instructions: 1180834208 heap_increase: 0 stable_memory_increase: 46 scopes: {} btreemap_v2_insert_blob_16_128: total: calls: 1 - instructions: 486249812 + instructions: 486246194 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_blob_256_128: total: calls: 1 - instructions: 1789038066 + instructions: 1789034049 heap_increase: 0 stable_memory_increase: 67 scopes: {} + btreemap_v2_insert_blob_32_0: + total: + calls: 1 + instructions: 490455134 + heap_increase: 0 + stable_memory_increase: 8 + scopes: {} btreemap_v2_insert_blob_32_1024: total: calls: 1 - instructions: 703500065 + instructions: 703496225 heap_increase: 0 stable_memory_increase: 173 scopes: {} btreemap_v2_insert_blob_32_128: total: calls: 1 - instructions: 542568143 + instructions: 542564351 heap_increase: 0 stable_memory_increase: 28 scopes: {} btreemap_v2_insert_blob_32_16: total: calls: 1 - instructions: 519117156 + instructions: 519113244 heap_increase: 0 stable_memory_increase: 11 scopes: {} btreemap_v2_insert_blob_32_256: total: calls: 1 - instructions: 570690137 + instructions: 570686267 heap_increase: 0 stable_memory_increase: 49 scopes: {} btreemap_v2_insert_blob_32_32: total: calls: 1 - instructions: 528951192 + instructions: 528947313 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_32_4: total: calls: 1 - instructions: 509380036 + instructions: 509376109 heap_increase: 0 stable_memory_increase: 8 scopes: {} btreemap_v2_insert_blob_32_512: total: calls: 1 - instructions: 610063051 + instructions: 610059178 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_blob_32_64: total: calls: 1 - instructions: 534921249 + instructions: 534917409 heap_increase: 0 stable_memory_increase: 18 scopes: {} btreemap_v2_insert_blob_32_8: total: calls: 1 - instructions: 517593840 + instructions: 517590057 heap_increase: 0 stable_memory_increase: 9 scopes: {} btreemap_v2_insert_blob_4_128: total: calls: 1 - instructions: 407268940 + instructions: 407266843 heap_increase: 0 stable_memory_increase: 13 scopes: {} btreemap_v2_insert_blob_512_128: total: calls: 1 - instructions: 3041223382 + instructions: 3041219347 heap_increase: 0 stable_memory_increase: 111 scopes: {} btreemap_v2_insert_blob_64_128: total: calls: 1 - instructions: 661179485 + instructions: 661175552 heap_increase: 0 stable_memory_increase: 34 scopes: {} btreemap_v2_insert_blob_8_128: total: calls: 1 - instructions: 458615568 + instructions: 458612442 heap_increase: 0 stable_memory_increase: 20 scopes: {} + btreemap_v2_insert_principal: + total: + calls: 1 + instructions: 499547411 + heap_increase: 0 + stable_memory_increase: 7 + scopes: {} btreemap_v2_insert_u64_blob8: total: calls: 1 - instructions: 406744693 + instructions: 406739905 heap_increase: 0 stable_memory_increase: 5 scopes: {} btreemap_v2_insert_u64_u64: total: calls: 1 - instructions: 414580548 + instructions: 414575469 heap_increase: 0 stable_memory_increase: 6 scopes: {} btreemap_v2_insert_u64_vec8: total: calls: 1 - instructions: 410372254 + instructions: 410368222 heap_increase: 0 stable_memory_increase: 21 scopes: {} btreemap_v2_insert_vec8_u64: total: calls: 1 - instructions: 594103663 + instructions: 594100537 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_1024_128: total: calls: 1 - instructions: 2744606200 + instructions: 2744513878 heap_increase: 0 stable_memory_increase: 193 scopes: {} btreemap_v2_insert_vec_128_128: total: calls: 1 - instructions: 1012643373 + instructions: 1012625574 heap_increase: 0 stable_memory_increase: 51 scopes: {} btreemap_v2_insert_vec_16_128: total: calls: 1 - instructions: 708997439 + instructions: 708984362 heap_increase: 0 stable_memory_increase: 31 scopes: {} btreemap_v2_insert_vec_256_128: total: calls: 1 - instructions: 1402219761 + instructions: 1402182234 heap_increase: 0 stable_memory_increase: 71 scopes: {} + btreemap_v2_insert_vec_32_0: + total: + calls: 1 + instructions: 621845953 + heap_increase: 0 + stable_memory_increase: 20 + scopes: {} btreemap_v2_insert_vec_32_1024: total: calls: 1 - instructions: 1182132701 + instructions: 1182054323 heap_increase: 0 stable_memory_increase: 171 scopes: {} btreemap_v2_insert_vec_32_128: total: calls: 1 - instructions: 756106158 + instructions: 756092289 heap_increase: 0 stable_memory_increase: 33 scopes: {} btreemap_v2_insert_vec_32_16: total: calls: 1 - instructions: 666191903 + instructions: 666188006 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_256: total: calls: 1 - instructions: 869225881 + instructions: 869200138 heap_increase: 0 stable_memory_increase: 54 scopes: {} btreemap_v2_insert_vec_32_32: total: calls: 1 - instructions: 661645394 + instructions: 661641515 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_4: total: calls: 1 - instructions: 660354036 + instructions: 660350181 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_32_512: total: calls: 1 - instructions: 973664463 + instructions: 973623252 heap_increase: 0 stable_memory_increase: 91 scopes: {} btreemap_v2_insert_vec_32_64: total: calls: 1 - instructions: 691643081 + instructions: 691630844 heap_increase: 0 stable_memory_increase: 24 scopes: {} btreemap_v2_insert_vec_32_8: total: calls: 1 - instructions: 659845953 + instructions: 659842170 heap_increase: 0 stable_memory_increase: 20 scopes: {} btreemap_v2_insert_vec_4_128: total: calls: 1 - instructions: 604355928 + instructions: 604348722 heap_increase: 0 stable_memory_increase: 16 scopes: {} btreemap_v2_insert_vec_512_128: total: calls: 1 - instructions: 1859161681 + instructions: 1859108239 heap_increase: 0 stable_memory_increase: 112 scopes: {} btreemap_v2_insert_vec_64_128: total: calls: 1 - instructions: 846320282 + instructions: 846297779 heap_increase: 0 stable_memory_increase: 41 scopes: {} btreemap_v2_insert_vec_8_128: total: calls: 1 - instructions: 666289233 + instructions: 666278550 heap_increase: 0 stable_memory_increase: 23 scopes: {} @@ -912,616 +975,658 @@ benches: btreemap_v2_mem_manager_insert_blob512_u64: total: calls: 1 - instructions: 3127680452 + instructions: 3127693876 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_blob512: total: calls: 1 - instructions: 607288370 + instructions: 607302030 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_u64: total: calls: 1 - instructions: 520545864 + instructions: 520562305 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_u64_vec512: total: calls: 1 - instructions: 834100595 + instructions: 834230066 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_insert_vec512_u64: total: calls: 1 - instructions: 1964405448 + instructions: 1964533302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_blob512_u64: total: calls: 1 - instructions: 4310221225 + instructions: 4310230683 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_blob512: total: calls: 1 - instructions: 882970074 + instructions: 882979670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_u64: total: calls: 1 - instructions: 736785650 + instructions: 736797990 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_u64_vec512: total: calls: 1 - instructions: 1223804753 + instructions: 1223992077 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_mem_manager_remove_vec512_u64: total: calls: 1 - instructions: 3084565257 + instructions: 3084753399 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob8_u64: total: calls: 1 - instructions: 599256189 + instructions: 599252070 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_1024_128: total: calls: 1 - instructions: 8387602842 + instructions: 8387598840 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_128_128: total: calls: 1 - instructions: 1824725965 + instructions: 1824721939 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_16_128: total: calls: 1 - instructions: 743084112 + instructions: 743080488 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_256_128: total: calls: 1 - instructions: 2763911828 + instructions: 2763907811 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_blob_32_0: + total: + calls: 1 + instructions: 751493486 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_1024: total: calls: 1 - instructions: 1121481321 + instructions: 1121477481 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_128: total: calls: 1 - instructions: 860285162 + instructions: 860281370 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_16: total: calls: 1 - instructions: 795095715 + instructions: 795091803 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_256: total: calls: 1 - instructions: 891739804 + instructions: 891735934 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_32: total: calls: 1 - instructions: 808560505 + instructions: 808556626 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_4: total: calls: 1 - instructions: 778864648 + instructions: 778860667 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_512: total: calls: 1 - instructions: 957571175 + instructions: 957567308 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_64: total: calls: 1 - instructions: 817406508 + instructions: 817402668 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_32_8: total: calls: 1 - instructions: 796779002 + instructions: 796775177 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_4_128: total: calls: 1 - instructions: 371435725 + instructions: 371433628 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_512_128: total: calls: 1 - instructions: 4613700344 + instructions: 4613696303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_64_128: total: calls: 1 - instructions: 1031695256 + instructions: 1031691323 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_blob_8_128: total: calls: 1 - instructions: 604976184 + instructions: 604973040 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_principal: + total: + calls: 1 + instructions: 762493239 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_blob8: total: calls: 1 - instructions: 669276877 + instructions: 669272017 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_u64: total: calls: 1 - instructions: 681264462 + instructions: 681259383 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_u64_vec8: total: calls: 1 - instructions: 671829217 + instructions: 671825185 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec8_u64: total: calls: 1 - instructions: 782876135 + instructions: 782873009 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_1024_128: total: calls: 1 - instructions: 4049265076 + instructions: 4049152840 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_128_128: total: calls: 1 - instructions: 1503218744 + instructions: 1503200945 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_16_128: total: calls: 1 - instructions: 1024772148 + instructions: 1024759071 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_256_128: total: calls: 1 - instructions: 2019891066 + instructions: 2019833997 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_first_vec_32_0: + total: + calls: 1 + instructions: 862942768 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_1024: total: calls: 1 - instructions: 1689829372 + instructions: 1689732148 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_128: total: calls: 1 - instructions: 1088869698 + instructions: 1088853861 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_16: total: calls: 1 - instructions: 928270806 + instructions: 928266909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_256: total: calls: 1 - instructions: 1215466767 + instructions: 1215441024 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_32: total: calls: 1 - instructions: 931028208 + instructions: 931024329 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_4: total: calls: 1 - instructions: 914745699 + instructions: 914741844 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_512: total: calls: 1 - instructions: 1373268399 + instructions: 1373208474 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_64: total: calls: 1 - instructions: 972735601 + instructions: 972723364 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_32_8: total: calls: 1 - instructions: 924967663 + instructions: 924963880 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_4_128: total: calls: 1 - instructions: 540984708 + instructions: 540977502 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_512_128: total: calls: 1 - instructions: 2716330411 + instructions: 2716276969 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_64_128: total: calls: 1 - instructions: 1234556907 + instructions: 1234517190 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_first_vec_8_128: total: calls: 1 - instructions: 850734232 + instructions: 850723549 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob8_u64: total: calls: 1 - instructions: 575661530 + instructions: 575657399 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_1024_128: total: calls: 1 - instructions: 8055247791 + instructions: 8055243789 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_128_128: total: calls: 1 - instructions: 1755509118 + instructions: 1755505092 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_16_128: total: calls: 1 - instructions: 716556083 + instructions: 716552465 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_256_128: total: calls: 1 - instructions: 2669730307 + instructions: 2669726290 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_blob_32_0: + total: + calls: 1 + instructions: 723331257 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_1024: total: calls: 1 - instructions: 1085450731 + instructions: 1085446885 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_128: total: calls: 1 - instructions: 825902306 + instructions: 825898514 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_16: total: calls: 1 - instructions: 766901397 + instructions: 766897485 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_256: total: calls: 1 - instructions: 860879651 + instructions: 860875781 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_32: total: calls: 1 - instructions: 775936416 + instructions: 775932537 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_4: total: calls: 1 - instructions: 755124599 + instructions: 755120630 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_512: total: calls: 1 - instructions: 932320719 + instructions: 932316858 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_64: total: calls: 1 - instructions: 791545690 + instructions: 791541850 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_32_8: total: calls: 1 - instructions: 768161716 + instructions: 768157909 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_4_128: total: calls: 1 - instructions: 357885021 + instructions: 357882924 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_512_128: total: calls: 1 - instructions: 4444567386 + instructions: 4444563339 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_64_128: total: calls: 1 - instructions: 999738711 + instructions: 999734778 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_blob_8_128: total: calls: 1 - instructions: 598942864 + instructions: 598939732 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_principal: + total: + calls: 1 + instructions: 745839855 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_blob8: total: calls: 1 - instructions: 645812582 + instructions: 645807686 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_u64: total: calls: 1 - instructions: 657455588 + instructions: 657450509 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_u64_vec8: total: calls: 1 - instructions: 648268033 + instructions: 648264001 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec8_u64: total: calls: 1 - instructions: 759547094 + instructions: 759543968 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_1024_128: total: calls: 1 - instructions: 4254818123 + instructions: 4254705881 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_128_128: total: calls: 1 - instructions: 1509650210 + instructions: 1509632411 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_16_128: total: calls: 1 - instructions: 1006125814 + instructions: 1006112737 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_256_128: total: calls: 1 - instructions: 2073363853 + instructions: 2073306796 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_pop_last_vec_32_0: + total: + calls: 1 + instructions: 846105831 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_1024: total: calls: 1 - instructions: 1664437667 + instructions: 1664340419 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_128: total: calls: 1 - instructions: 1064611264 + instructions: 1064595433 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_16: total: calls: 1 - instructions: 902974455 + instructions: 902970558 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_256: total: calls: 1 - instructions: 1193452039 + instructions: 1193426296 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_32: total: calls: 1 - instructions: 910490347 + instructions: 910486468 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_4: total: calls: 1 - instructions: 898985596 + instructions: 898981741 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_512: total: calls: 1 - instructions: 1356914135 + instructions: 1356854198 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_64: total: calls: 1 - instructions: 949782755 + instructions: 949770518 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_32_8: total: calls: 1 - instructions: 902473492 + instructions: 902469709 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_4_128: total: calls: 1 - instructions: 527064939 + instructions: 527057733 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_512_128: total: calls: 1 - instructions: 2808165041 + instructions: 2808111599 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_64_128: total: calls: 1 - instructions: 1220824533 + instructions: 1220784792 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_pop_last_vec_8_128: total: calls: 1 - instructions: 850619579 + instructions: 850608896 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1591,280 +1696,301 @@ benches: btreemap_v2_remove_10mib_values: total: calls: 1 - instructions: 4711118385 + instructions: 4709565702 heap_increase: 0 stable_memory_increase: 657 scopes: {} btreemap_v2_remove_blob8_u64: total: calls: 1 - instructions: 584636969 + instructions: 584632796 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_1024_128: total: calls: 1 - instructions: 7363800309 + instructions: 7363796307 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_128_128: total: calls: 1 - instructions: 1588756329 + instructions: 1588752303 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_16_128: total: calls: 1 - instructions: 665337905 + instructions: 665334293 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_256_128: total: calls: 1 - instructions: 2421697300 + instructions: 2421693283 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_blob_32_0: + total: + calls: 1 + instructions: 654246003 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_1024: total: calls: 1 - instructions: 985325869 + instructions: 985322023 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_128: total: calls: 1 - instructions: 746608890 + instructions: 746605092 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_16: total: calls: 1 - instructions: 700059994 + instructions: 700056094 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_256: total: calls: 1 - instructions: 784125701 + instructions: 784121825 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_32: total: calls: 1 - instructions: 711919498 + instructions: 711915619 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_4: total: calls: 1 - instructions: 696214241 + instructions: 696210302 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_512: total: calls: 1 - instructions: 857936684 + instructions: 857932817 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_64: total: calls: 1 - instructions: 737074307 + instructions: 737070467 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_32_8: total: calls: 1 - instructions: 696057915 + instructions: 696054096 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_4_128: total: calls: 1 - instructions: 452857933 + instructions: 452855812 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_512_128: total: calls: 1 - instructions: 4071507249 + instructions: 4071503214 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_64_128: total: calls: 1 - instructions: 910052271 + instructions: 910048338 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_blob_8_128: total: calls: 1 - instructions: 599299651 + instructions: 599296531 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_principal: + total: + calls: 1 + instructions: 664229324 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_blob8: total: calls: 1 - instructions: 566079913 + instructions: 566075041 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_u64: total: calls: 1 - instructions: 586718731 + instructions: 586713652 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_u64_vec8: total: calls: 1 - instructions: 571366355 + instructions: 571362323 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec8_u64: total: calls: 1 - instructions: 755823918 + instructions: 755820792 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_1024_128: total: calls: 1 - instructions: 4475943466 + instructions: 4475823940 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_128_128: total: calls: 1 - instructions: 1418213214 + instructions: 1418195415 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_16_128: total: calls: 1 - instructions: 921111290 + instructions: 921098213 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_256_128: total: calls: 1 - instructions: 2244668594 + instructions: 2244605357 + heap_increase: 0 + stable_memory_increase: 0 + scopes: {} + btreemap_v2_remove_vec_32_0: + total: + calls: 1 + instructions: 834326197 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_1024: total: calls: 1 - instructions: 1701563272 + instructions: 1701459670 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_128: total: calls: 1 - instructions: 1036968514 + instructions: 1036942087 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_16: total: calls: 1 - instructions: 871328883 + instructions: 871324986 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_256: total: calls: 1 - instructions: 1240176546 + instructions: 1240150803 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_32: total: calls: 1 - instructions: 867569469 + instructions: 867565590 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_4: total: calls: 1 - instructions: 862147420 + instructions: 862143565 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_512: total: calls: 1 - instructions: 1405971132 + instructions: 1405903551 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_64: total: calls: 1 - instructions: 968312981 + instructions: 968300744 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_32_8: total: calls: 1 - instructions: 856477157 + instructions: 856473374 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_4_128: total: calls: 1 - instructions: 662121914 + instructions: 662114708 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_512_128: total: calls: 1 - instructions: 3082706271 + instructions: 3082652829 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_64_128: total: calls: 1 - instructions: 1183958569 + instructions: 1183921648 heap_increase: 0 stable_memory_increase: 0 scopes: {} btreemap_v2_remove_vec_8_128: total: calls: 1 - instructions: 821774415 + instructions: 821763732 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/btreemap/src/main.rs b/benchmarks/btreemap/src/main.rs index bcc78fb0..be0f648d 100644 --- a/benchmarks/btreemap/src/main.rs +++ b/benchmarks/btreemap/src/main.rs @@ -1,5 +1,6 @@ use benchmarks::{random::Random, vec::UnboundedVecN}; use canbench_rs::{bench, bench_fn, BenchResult}; +use candid::Principal; use ic_stable_structures::memory_manager::{MemoryId, MemoryManager}; use ic_stable_structures::{storable::Blob, BTreeMap, DefaultMemoryImpl, Memory, Storable}; use std::ops::Bound; @@ -27,6 +28,8 @@ type UnboundedVecN256 = UnboundedVecN<256>; type UnboundedVecN512 = UnboundedVecN<512>; type UnboundedVecN1024 = UnboundedVecN<1024>; +type Empty = (); + #[allow(non_upper_case_globals)] const KiB: usize = 1024; #[allow(non_upper_case_globals)] @@ -78,6 +81,7 @@ bench_tests! { btreemap_v2_insert_blob_1024_128, insert_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_insert_blob_32_0, insert_helper_v2, Blob32, Empty; btreemap_v2_insert_blob_32_4, insert_helper_v2, Blob32, Blob4; btreemap_v2_insert_blob_32_8, insert_helper_v2, Blob32, Blob8; btreemap_v2_insert_blob_32_16, insert_helper_v2, Blob32, Blob16; @@ -100,6 +104,7 @@ bench_tests! { btreemap_v2_insert_vec_1024_128, insert_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_insert_vec_32_0, insert_helper_v2, UnboundedVecN32, Empty; btreemap_v2_insert_vec_32_4, insert_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_insert_vec_32_8, insert_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_insert_vec_32_16, insert_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -117,6 +122,9 @@ bench_tests! { btreemap_v2_insert_u64_vec8, insert_helper_v2, u64, UnboundedVecN8; btreemap_v2_insert_vec8_u64, insert_helper_v2, UnboundedVecN8, u64; + // Principal + btreemap_v2_insert_principal, insert_helper_v2, Principal, Empty; + // memory manager u64 / blob512 / vec512 btreemap_v2_mem_manager_insert_u64_u64, insert_helper_v2_mem_manager, u64, u64; btreemap_v2_mem_manager_insert_u64_blob512, insert_helper_v2_mem_manager, u64, Blob512; @@ -178,6 +186,7 @@ bench_tests! { btreemap_v2_remove_blob_1024_128, remove_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_remove_blob_32_0, remove_helper_v2, Blob32, Empty; btreemap_v2_remove_blob_32_4, remove_helper_v2, Blob32, Blob4; btreemap_v2_remove_blob_32_8, remove_helper_v2, Blob32, Blob8; btreemap_v2_remove_blob_32_16, remove_helper_v2, Blob32, Blob16; @@ -200,6 +209,7 @@ bench_tests! { btreemap_v2_remove_vec_1024_128, remove_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_remove_vec_32_0, remove_helper_v2, UnboundedVecN32, Empty; btreemap_v2_remove_vec_32_4, remove_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_remove_vec_32_8, remove_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_remove_vec_32_16, remove_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -217,6 +227,9 @@ bench_tests! { btreemap_v2_remove_u64_vec8, remove_helper_v2, u64, UnboundedVecN8; btreemap_v2_remove_vec8_u64, remove_helper_v2, UnboundedVecN8, u64; + // Principal + btreemap_v2_remove_principal, remove_helper_v2, Principal, Empty; + // memory manager u64 / blob512 / vec512 btreemap_v2_mem_manager_remove_u64_u64, remove_helper_v2_mem_manager, u64, u64; btreemap_v2_mem_manager_remove_u64_blob512, remove_helper_v2_mem_manager, u64, Blob512; @@ -285,6 +298,7 @@ bench_tests! { btreemap_v2_get_blob_1024_128, get_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_get_blob_32_0, get_helper_v2, Blob32, Empty; btreemap_v2_get_blob_32_4, get_helper_v2, Blob32, Blob4; btreemap_v2_get_blob_32_8, get_helper_v2, Blob32, Blob8; btreemap_v2_get_blob_32_16, get_helper_v2, Blob32, Blob16; @@ -307,6 +321,7 @@ bench_tests! { btreemap_v2_get_vec_1024_128, get_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_get_vec_32_0, get_helper_v2, UnboundedVecN32, Empty; btreemap_v2_get_vec_32_4, get_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_get_vec_32_8, get_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_get_vec_32_16, get_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -324,6 +339,9 @@ bench_tests! { btreemap_v2_get_u64_vec8, get_helper_v2, u64, UnboundedVecN8; btreemap_v2_get_vec8_u64, get_helper_v2, UnboundedVecN8, u64; + // Principal + btreemap_v2_get_principal, get_helper_v2, Principal, Empty; + // memory manager u64 / blob512 / vec512 btreemap_v2_mem_manager_get_u64_u64, get_helper_v2_mem_manager, u64, u64; btreemap_v2_mem_manager_get_u64_blob512, get_helper_v2_mem_manager, u64, Blob512; @@ -392,6 +410,7 @@ bench_tests! { btreemap_v2_contains_blob_1024_128, contains_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_contains_blob_32_0, contains_helper_v2, Blob32, Empty; btreemap_v2_contains_blob_32_4, contains_helper_v2, Blob32, Blob4; btreemap_v2_contains_blob_32_8, contains_helper_v2, Blob32, Blob8; btreemap_v2_contains_blob_32_16, contains_helper_v2, Blob32, Blob16; @@ -414,6 +433,7 @@ bench_tests! { btreemap_v2_contains_vec_1024_128, contains_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_contains_vec_32_0, contains_helper_v2, UnboundedVecN32, Empty; btreemap_v2_contains_vec_32_4, contains_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_contains_vec_32_8, contains_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_contains_vec_32_16, contains_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -431,6 +451,9 @@ bench_tests! { btreemap_v2_contains_u64_vec8, contains_helper_v2, u64, UnboundedVecN8; btreemap_v2_contains_vec8_u64, contains_helper_v2, UnboundedVecN8, u64; + // Principal + btreemap_v2_contains_principal, contains_helper_v2, Principal, Empty; + // memory manager u64 / blob512 / vec512 btreemap_v2_mem_manager_contains_u64_u64, contains_helper_v2_mem_manager, u64, u64; btreemap_v2_mem_manager_contains_u64_blob512, contains_helper_v2_mem_manager, u64, Blob512; @@ -521,6 +544,7 @@ bench_tests! { btreemap_v2_pop_first_blob_1024_128, pop_first_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_pop_first_blob_32_0, pop_first_helper_v2, Blob32, Empty; btreemap_v2_pop_first_blob_32_4, pop_first_helper_v2, Blob32, Blob4; btreemap_v2_pop_first_blob_32_8, pop_first_helper_v2, Blob32, Blob8; btreemap_v2_pop_first_blob_32_16, pop_first_helper_v2, Blob32, Blob16; @@ -543,6 +567,7 @@ bench_tests! { btreemap_v2_pop_first_vec_1024_128, pop_first_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_pop_first_vec_32_0, pop_first_helper_v2, UnboundedVecN32, Empty; btreemap_v2_pop_first_vec_32_4, pop_first_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_pop_first_vec_32_8, pop_first_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_pop_first_vec_32_16, pop_first_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -559,6 +584,9 @@ bench_tests! { btreemap_v2_pop_first_blob8_u64, pop_first_helper_v2, Blob8, u64; btreemap_v2_pop_first_u64_vec8, pop_first_helper_v2, u64, UnboundedVecN8; btreemap_v2_pop_first_vec8_u64, pop_first_helper_v2, UnboundedVecN8, u64; + + // Principal + btreemap_v2_pop_first_principal, pop_first_helper_v2, Principal, Empty; } // Last @@ -575,6 +603,7 @@ bench_tests! { btreemap_v2_pop_last_blob_1024_128, pop_last_helper_v2, Blob1024, Blob128; // blob 32 x V + btreemap_v2_pop_last_blob_32_0, pop_last_helper_v2, Blob32, Empty; btreemap_v2_pop_last_blob_32_4, pop_last_helper_v2, Blob32, Blob4; btreemap_v2_pop_last_blob_32_8, pop_last_helper_v2, Blob32, Blob8; btreemap_v2_pop_last_blob_32_16, pop_last_helper_v2, Blob32, Blob16; @@ -597,6 +626,7 @@ bench_tests! { btreemap_v2_pop_last_vec_1024_128, pop_last_helper_v2, UnboundedVecN1024, UnboundedVecN128; // vec 32 x V + btreemap_v2_pop_last_vec_32_0, pop_last_helper_v2, UnboundedVecN32, Empty; btreemap_v2_pop_last_vec_32_4, pop_last_helper_v2, UnboundedVecN32, UnboundedVecN4; btreemap_v2_pop_last_vec_32_8, pop_last_helper_v2, UnboundedVecN32, UnboundedVecN8; btreemap_v2_pop_last_vec_32_16, pop_last_helper_v2, UnboundedVecN32, UnboundedVecN16; @@ -613,6 +643,9 @@ bench_tests! { btreemap_v2_pop_last_blob8_u64, pop_last_helper_v2, Blob8, u64; btreemap_v2_pop_last_u64_vec8, pop_last_helper_v2, u64, UnboundedVecN8; btreemap_v2_pop_last_vec8_u64, pop_last_helper_v2, UnboundedVecN8, u64; + + // Principal + btreemap_v2_pop_last_principal, pop_last_helper_v2, Principal, Empty; } fn pop_first_helper_v2() -> BenchResult { diff --git a/benchmarks/src/random.rs b/benchmarks/src/random.rs index e5fc08ee..d9017508 100644 --- a/benchmarks/src/random.rs +++ b/benchmarks/src/random.rs @@ -1,4 +1,5 @@ use crate::vec::{BoundedVecN, UnboundedVecN}; +use candid::Principal; use ic_stable_structures::storable::{Blob, Storable}; use tiny_rng::{Rand, Rng}; @@ -46,3 +47,18 @@ impl Random for u64 { rng.rand_u64() } } + +impl Random for Principal { + fn random(rng: &mut Rng) -> Self { + let size = rng.rand_u32() % Principal::MAX_LENGTH_IN_BYTES as u32; + let mut buf = Vec::with_capacity(size as usize); + for _ in 0..size { + buf.push(rng.rand_u8()); + } + Principal::from_slice(&buf) + } +} + +impl Random for () { + fn random(_: &mut Rng) -> Self {} +} From 10d3a91c6f784bc29ffdf8b1f1676398ea193dd9 Mon Sep 17 00:00:00 2001 From: Maksym Arutyunyan Date: Tue, 15 Jul 2025 10:41:36 +0200 Subject: [PATCH 2/2] assure no 0-size principals --- benchmarks/btreemap/canbench_results.yml | 14 +++++++------- benchmarks/src/random.rs | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benchmarks/btreemap/canbench_results.yml b/benchmarks/btreemap/canbench_results.yml index b0905770..4d164584 100644 --- a/benchmarks/btreemap/canbench_results.yml +++ b/benchmarks/btreemap/canbench_results.yml @@ -142,7 +142,7 @@ benches: btreemap_v2_contains_principal: total: calls: 1 - instructions: 343900374 + instructions: 349062610 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -443,7 +443,7 @@ benches: btreemap_v2_get_principal: total: calls: 1 - instructions: 351261213 + instructions: 356428202 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -744,9 +744,9 @@ benches: btreemap_v2_insert_principal: total: calls: 1 - instructions: 499547411 + instructions: 503303086 heap_increase: 0 - stable_memory_increase: 7 + stable_memory_increase: 8 scopes: {} btreemap_v2_insert_u64_blob8: total: @@ -1178,7 +1178,7 @@ benches: btreemap_v2_pop_first_principal: total: calls: 1 - instructions: 762493239 + instructions: 800186729 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1472,7 +1472,7 @@ benches: btreemap_v2_pop_last_principal: total: calls: 1 - instructions: 745839855 + instructions: 780286737 heap_increase: 0 stable_memory_increase: 0 scopes: {} @@ -1836,7 +1836,7 @@ benches: btreemap_v2_remove_principal: total: calls: 1 - instructions: 664229324 + instructions: 684154256 heap_increase: 0 stable_memory_increase: 0 scopes: {} diff --git a/benchmarks/src/random.rs b/benchmarks/src/random.rs index d9017508..26ff04a3 100644 --- a/benchmarks/src/random.rs +++ b/benchmarks/src/random.rs @@ -50,7 +50,7 @@ impl Random for u64 { impl Random for Principal { fn random(rng: &mut Rng) -> Self { - let size = rng.rand_u32() % Principal::MAX_LENGTH_IN_BYTES as u32; + let size = 1 + (rng.rand_u32() % (Principal::MAX_LENGTH_IN_BYTES as u32 - 1)); let mut buf = Vec::with_capacity(size as usize); for _ in 0..size { buf.push(rng.rand_u8());