go-hashmap, v1.3-alpha.1
Posted on

The library that implements a hash map with synchronized and concurrent wrappers.
Support iteration over items and their keys.
Change Log
- support iteration over items and their keys:
- for a hash map;
- for a synchronized hash map;
- for a concurrent hash map.
Features
- implementation of a hash map:
- use the open addressing strategy for collision resolution;
- use the key interface for supporting custom types;
- support operations:
- getting of an item by a key;
- iteration over items and their keys;
- setting of an item by a key;
- deleting of an item by a key;
- implementation of a synchronized hash map:
- use the implementation described above as an inner map;
- use a mutex lock to access the inner map;
- support operations:
- getting of an item by a key;
- iteration over items and their keys;
- setting of an item by a key;
- deleting of an item by a key;
- implementation of a concurrent hash map:
- use data sharding for concurrent access;
- use the synchronized implementation described above as one shard;
- support operations:
- getting of an item by a key;
- iteration over items and their keys;
- setting of an item by a key;
- deleting of an item by a key.
Benchmarks
SynchronizedHashMap & ConcurrentHashMap
BenchmarkSynchronizedBuiltinMap/Iterate/1000/1-8 50000 32131 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedBuiltinMap/Iterate/1000/10-8 3000 459726 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedBuiltinMap/Iterate/1000/100-8 300 4444310 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedBuiltinMap/Iterate/1000/1000-8 30 41883860 ns/op 16 B/op 1 allocs/op
BenchmarkSyncMap/Iterate/1000/1-8 100000 22828 ns/op 16 B/op 1 allocs/op
BenchmarkSyncMap/Iterate/1000/10-8 10000 116762 ns/op 16 B/op 1 allocs/op
BenchmarkSyncMap/Iterate/1000/100-8 2000 589207 ns/op 16 B/op 1 allocs/op
BenchmarkSyncMap/Iterate/1000/1000-8 300 5422958 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedHashMap/Iterate/1000/1-8 20000 74172 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedHashMap/Iterate/1000/10-8 2000 775545 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedHashMap/Iterate/1000/100-8 200 6471434 ns/op 16 B/op 1 allocs/op
BenchmarkSynchronizedHashMap/Iterate/1000/1000-8 20 80407003 ns/op 28 B/op 1 allocs/op
BenchmarkConcurrentHashMap/Iterate/1000/1-8 20000 67734 ns/op 16 B/op 1 allocs/op
BenchmarkConcurrentHashMap/Iterate/1000/10-8 5000 323617 ns/op 16 B/op 1 allocs/op
BenchmarkConcurrentHashMap/Iterate/1000/100-8 1000 1962246 ns/op 19 B/op 1 allocs/op
BenchmarkConcurrentHashMap/Iterate/1000/1000-8 100 16390170 ns/op 377 B/op 1 allocs/op
HashMap
BenchmarkBuiltinMap/Iterate/10-8 10000000 153 ns/op 0 B/op 0 allocs/op
BenchmarkBuiltinMap/Iterate/100-8 1000000 1420 ns/op 0 B/op 0 allocs/op
BenchmarkBuiltinMap/Iterate/1000-8 100000 16302 ns/op 0 B/op 0 allocs/op
BenchmarkBuiltinMap/Iterate/10000-8 10000 158305 ns/op 0 B/op 0 allocs/op
BenchmarkBuiltinMap/Iterate/100000-8 1000 1601750 ns/op 0 B/op 0 allocs/op
BenchmarkBuiltinMap/Iterate/1000000-8 50 20097513 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/10-8 30000000 35 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/100-8 5000000 335 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/1000-8 300000 3695 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/10000-8 20000 68884 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/100000-8 2000 1076886 ns/op 0 B/op 0 allocs/op
BenchmarkHashMap/Iterate/1000000-8 100 19157103 ns/op 0 B/op 0 allocs/op
Repository
Link: https://github.com/thewizardplusplus/go-hashmap/tree/v1.3-alpha.1.
Content: code.
License: MIT.