<s> import logging <EOL> import sys <EOL> from os . path import dirname <EOL> import time <EOL> import hazelcast <EOL> from hazelcast . config import NearCacheConfig , IN_MEMORY_FORMAT <EOL> sys . path . append ( dirname ( dirname ( dirname ( __file__ ) ) ) ) <EOL> MAP_NAME = "<STR_LIT:default>" <EOL> THREAD_COUNT = <NUM_LIT:1> <EOL> ENTRY_COUNT = <NUM_LIT> <EOL> VALUE_SIZE = <NUM_LIT:100> <EOL> GET_PERCENTAGE = <NUM_LIT:100> <EOL> PUT_PERCENTAGE = <NUM_LIT:0> <EOL> VALUE = "<STR_LIT:x>" * VALUE_SIZE <EOL> def init ( ) : <EOL> logging . basicConfig ( format = '<STR_LIT>' , datefmt = "<STR_LIT>" ) <EOL> logging . getLogger ( ) . setLevel ( logging . INFO ) <EOL> logger = logging . getLogger ( "<STR_LIT>" ) <EOL> config = hazelcast . ClientConfig ( ) <EOL> config . group_config . name = "<STR_LIT>" <EOL> config . group_config . password = "<STR_LIT>" <EOL> config . network_config . addresses . append ( "<STR_LIT>" ) <EOL> near_cache_config = NearCacheConfig ( MAP_NAME ) <EOL> near_cache_config . in_memory_format = IN_MEMORY_FORMAT . OBJECT <EOL> config . add_near_cache_config ( near_cache_config ) <EOL> client = hazelcast . HazelcastClient ( config ) <EOL> my_map = client . get_map ( MAP_NAME ) . blocking ( ) <EOL> print "<STR_LIT>" <EOL> for key in xrange ( <NUM_LIT:0> , ENTRY_COUNT ) : <EOL> my_map . put ( key , VALUE ) <EOL> for key in xrange ( <NUM_LIT:0> , ENTRY_COUNT ) : <EOL> my_map . get ( key ) <EOL> print "<STR_LIT>" <EOL> return my_map <EOL> def bench ( my_map ) : <EOL> start = time . time ( ) <EOL> hit = my_map . _near_cache . _cache_hit <EOL> for key in xrange ( <NUM_LIT:0> , ENTRY_COUNT ) : <EOL> my_map . get ( key ) <EOL> print "<STR_LIT>" , ENTRY_COUNT / ( time . time ( ) - start ) , "<STR_LIT>" , my_map . _near_cache . _cache_hit - hit <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _map = init ( ) <EOL> bench ( _map ) </s>
