uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
uint32 hash_c( const char * str) { uint32 h = 0; const int len = strlen(str); for ( int i = 0; i < len; ++i) h = 31*h + str[i]; return h; } uint32 hash_stl( const std:: string & str) { uint32 h = 0; for (std:: string ::const_iterator it = str.begin(); it != str.end(); ++it) h = 31*h + + *it; return h; } * This source code was highlighted with Source Code Highlighter .
* This source code was highlighted with Source Code Highlighter .
- #define ITERATION_COUNT 256 * 1024
- // ...
- for ( int i = 0; i <ITERATION_COUNT; ++ i)
- h1 = hash_c (str);
- // ...
- for ( int i = 0; i <ITERATION_COUNT; ++ i)
- h2 = hash_stl (str);
* This source code was highlighted with Source Code Highlighter .
- cl / EHsc / O2 main.cpp
- **************************************
- string length: 8 bytes
- const char *: 6.20 msec, hash: 312017024
- std :: string : 12.62 msec, hash: 312017024, 2.04x
- total allocs: 0
- **************************************
- string length: 16 bytes
- const char *: 11.78 msec, hash: 2657714432
- std :: string : 131.21 msec, hash: 2657714432, 11.14x
- total allocs: 262144
- **************************************
- string length: 32 bytes
- const char *: 23.20 msec, hash: 3820028416
- std :: string : 144.64 msec, hash: 3820028416, 6.24x
- total allocs: 262144
* This source code was highlighted with Source Code Highlighter .
- cl / EHsc / MDd / RTC1 / ZI main.cpp
- **************************************
- string length: 8 bytes
- const char *: 24.74 msec, hash: 312017024
- std :: string : 4260.18 msec, hash: 312017024, 172.23x
- total allocs: 262144
- **************************************
- string length: 16 bytes
- const char *: 34.87 msec, hash: 2657714432
- std :: string : 7697.69 msec, hash: 2657714432, 220.76x
- total allocs: 524288
- **************************************
- string length: 32 bytes
- const char *: 58.38 msec, hash: 3820028416
- std :: string : 14169.49 msec, hash: 3820028416, 242.70x
- total allocs: 524288
Source: https://habr.com/ru/post/131598/
All Articles