Hash Random Int Subscript Insert Timing Test (original) (raw)
Hash-Based Random-Integer operator[] Insert Timing Test
Description
This test inserts a number of values with uniform i.i.d. integer keys into a container, usingoperator[]. It measures the average time foroperator[] as a function of the number of values inserted.
(The test was executed with hash_random_int_subscript_insert_timing_test 200 200 2100)
Purpose
The test primarily checks the effect of different underlying hash-tables (see Design::Associative Containers::Associative Containers::Hash-Based Containers).
Results
Figures NCCG, NCCM, and NCCL show the results for the native and collision-chaining types in g++, MSVC++, andlocal, respectively; Figures NGPG, NGPM, and NGPL show the results for the native and probing types in g++, msvc++, andlocal respectively; Figures CCGPG, CCGPM, and CCGPL compare the results for the collision-chaining and probing types ofpb_ds only, in g++, MSVC++, andlocal respectively.
NCCL: Native and collision-chaining hash random int insert timing test using
operator
- local
NGPL: Native and probing hash random int insert timing test using
operator
- local
CCGPG: Collision-chaining and probing hash random int insert timing test using
operator
- g++
In the above figure, the names in the legends have the following meaning:
- gp_hash_mod_quadp_prime_nea_lc_1div8_1div2_nsth_map-gp_hash_table with Comb_Hash_Fn = direct_mod_range_hashing, Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_prime_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2, and Probe_Fn = quadratic_probe_fn
- cc_hash_mod_prime_nea_lc_1div8_1div2_nsth_map-cc_hash_tablewith Comb_Hash_Fn = direct_mod_range_hashing, and Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_prime_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2
- cc_hash_mask_exp_nea_lc_1div8_1div2_nsth_map-cc_hash_tablewith Comb_Hash_Fn = direct_mask_range_hashing, and Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_exponential_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2
- gp_hash_mask_linp_exp_nea_lc_1div8_1div2_nsth_map-gp_hash_table with Comb_Hash_Fn = direct_mask_range_hashing, Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_exponential_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2, and Probe_Fn = linear_probe_fn
CCGPM: Collision-chaining and probing hash random int insert timing test using
operator
- msvc++
In the above figure, the names in the legends have the following meaning:
- cc_hash_mod_prime_nea_lc_1div8_1div2_nsth_map-cc_hash_tablewith Comb_Hash_Fn = direct_mod_range_hashing, and Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_prime_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2
- cc_hash_mask_exp_nea_lc_1div8_1div2_nsth_map-cc_hash_tablewith Comb_Hash_Fn = direct_mask_range_hashing, and Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_exponential_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2
- gp_hash_mod_quadp_prime_nea_lc_1div8_1div2_nsth_map-gp_hash_table with Comb_Hash_Fn = direct_mod_range_hashing, Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_prime_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2, and Probe_Fn = quadratic_probe_fn
- gp_hash_mask_linp_exp_nea_lc_1div8_1div2_nsth_map-gp_hash_table with Comb_Hash_Fn = direct_mask_range_hashing, Resize_Policy = hash_standard_resize_policy with Size_Policy = hash_exponential_size_policy, and Trigger_Policy = hash_load_check_resize_trigger with αmin = 1/8 and αmax = 1/2, and Probe_Fn = linear_probe_fn
CCGPL: Collision-chaining and probing hash random int insert timing test using
operator
- local
Observations
In this setting, as in Hash-Based Textfind Find Timing Test and Hash-Based Random-Integer find Find Timing Test , the choice of underlying hash-table underlying hash-table (see Design::Associative Containers::Hash-Based Containers ) affects performance most, then the range-hashing scheme (See Design::Associative Containers::Hash-Based Containers::Hash Policies ), and, only finally, other policies.
There are some differences, however:
- In this setting, probing tables function sometimes more efficiently than collision-chaining tables (see FiguresCCGPG and CCGPM ). This is explained shortly.
- The performance graphs have a "saw-tooth" shape. The average insert time rises and falls. As values are inserted into the container, the load factor grows larger. Eventually, a resize occurs. The reallocations and rehashing are relatively expensive. After this, the load factor is smaller than before.
Collision-chaining containers use indirection for greater flexibility; probing containers store values contiguously, in an array (see Figure Motivation::Different underlying data structures A and B, respectively). It follows that for simple data types, probing containers access their allocator less frequently than collision-chaining containers, (although they still have less efficient probing sequences). This explains why some probing containers fare better than collision-chaining containers in this case.
Within each type of hash-table, the range-hashing scheme affects performance more than other policies. This is similar to the situation in Hash-Based Textfind Find Timing Test and Hash-Based Random-Integer find Find Timing Test. Unsurprisingly, however, containers with lower alphamax perform worse in this case, since more re-hashes are performed.
Observations::Hash-Based Container Types summarizes some observations on hash-based containers; Observations::Hash-Based Containers' Policies summarizes some observations on hash-based containers' policies.