This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'rubygems' | |
| require 'active_support' | |
| require "rbench" | |
| class Hash | |
| def fast_reverse_merge( other_hash ) | |
| self.merge( other_hash ){|k,o,n| o } | |
| end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ReverseMerge | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| def reverse_merge(other_hash) | |
| other_hash.merge(self) | |
| end | |
| # Performs the opposite of <tt>merge</tt>, with the keys and values from the first hash taking precedence over the second. | |
| # Modifies the receiver in place. | |
| def reverse_merge!(other_hash) | |
| replace(reverse_merge(other_hash)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 68425078408 -> numhash( 10209 ) | |
| 0 68425078413 <- 10209 numhash | |
| 0 68425078417 <- 0 st_insert | |
| 0 68425078422 -> st_lookup( <st_table num_bins: 283, num_entries: 958>, 677117, 4 ) | |
| 0 68425078428 -> strhash( ObjectSpace ) | |
| 0 68425078435 <- 3997301169 strhash | |
| 0 68425078439 <- 0 st_lookup | |
| 0 68425078444 -> st_add_direct( <st_table num_bins: 283, num_entries: 958>, 1181008, 10221 ) | |
| 0 68425078449 -> strhash( ObjectSpace ) | |
| 0 68425078455 <- 3997301169 strhash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 67232268168 -> numhash( 10204 ) | |
| 0 67232268173 <- 10204 numhash | |
| 0 67232268179 -> st_lookup( <st_table num_bins: 283, num_entries: 957>, 673940, 59452 ) | |
| 0 67232268184 -> strhash( allocate ) | |
| 0 67232268191 <- 948867196 strhash | |
| 0 67232268195 <- 1 st_lookup | |
| 0 67232268199 -> numhash( 10204 ) | |
| 0 67232268204 <- 10204 numhash | |
| 0 67232268209 -> st_lookup( <st_table num_bins: 283, num_entries: 957>, 677101, 28 ) | |
| 0 67232268215 -> strhash( garbage_collect ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 0 66912008017 -> st_init_table_with_size( 760124, 0 ) | |
| 0 66912008022 -> new_size( 1174848 ) | |
| 0 66912008026 <- 11 new_size | |
| 0 66912008031 <- st_init_table_with_size | |
| 0 66912008035 <- st_init_table | |
| 0 66912008038 <- st_init_numtable | |
| 0 66912008042 -> st_init_numtable(void) | |
| 0 66912008047 -> st_init_table( 760124 ) | |
| 0 66912008051 -> st_init_table_with_size( 760124, 0 ) | |
| 0 66912008056 -> new_size( 11 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 1 66617692509 -> strhash( Test ) | |
| 1 66617692515 <- 1796846687 strhash | |
| 1 66617692520 -> strhash( Test ) | |
| 1 66617692526 <- 1796846687 strhash | |
| 1 66617692530 -> numhash( 10653 ) | |
| 1 66617692535 <- 10653 numhash | |
| 1 66617692613 -> numhash( 10653 ) | |
| 1 66617692619 <- 10653 numhash | |
| 1 66617692623 -> numhash( 10653 ) | |
| 1 66617692627 <- 10653 numhash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifdef HASH_LOG | |
| static int collision = 0; | |
| static int init_st = 0; | |
| static void | |
| stat_col() | |
| { | |
| FILE *f = fopen("/tmp/col", "w"); | |
| fprintf(f, "collision: %d\n", collision); | |
| fclose(f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| strhash( setegid ) | |
| strhash( allocate ) | |
| numhash( 9697 ) | |
| strhash( setreuid ) | |
| strhash( setreuid ) | |
| numhash( 9705 ) | |
| strhash( initialize ) | |
| strhash( initialize_copy ) | |
| numhash( 9705 ) | |
| strhash( __attached__ ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct st_table { | |
| struct st_hash_type *type; | |
| int num_bins = 11; | |
| int num_entries = 1; | |
| struct st_table_entry **bins; | |
| }; | |
| struct st_table { | |
| struct st_hash_type *type; | |
| int num_bins = 283; | |
| int num_entries = 814; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/sbin/dtrace -s | |
| #pragma D option quiet | |
| typedef struct st_table { | |
| struct st_hash_type *type; | |
| int num_bins; | |
| int num_entries; | |
| struct st_table_entry **bins; | |
| } st_table_t; |