Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobvanluijt/golang-map-vs-struct-benchmark
Benchmark to test structs vs maps.
https://github.com/bobvanluijt/golang-map-vs-struct-benchmark
Last synced: 2 months ago
JSON representation
Benchmark to test structs vs maps.
- Host: GitHub
- URL: https://github.com/bobvanluijt/golang-map-vs-struct-benchmark
- Owner: bobvanluijt
- Created: 2018-02-07T11:46:04.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-02-07T12:31:44.000Z (almost 7 years ago)
- Last Synced: 2024-10-03T19:24:00.981Z (3 months ago)
- Language: Go
- Size: 4.88 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Generate json files
Run: `node --max_old_space_size=8183 generateJson.js`
Output: `Id to find: p_xxx` (replace xxx with the actual number)# Test
Test maps: `go run ./map/speedTest.go p_xxx`
Test structs: `go run ./struct/speedTest.go p_xxx`
# Struct:
```
type PropertiesA []struct {
History []struct {
Timestamp int64 `json:"timestamp"`
Value string `json:"value"`
} `json:"history"`
Property string `json:"property"`
}
```# Map:
```
type propertiesB map[string]map[string]string
```# Results
General balance history and items (resp: 125000, max 1100):
```
MAP QUERY FOUND: low4vvu5abdo2sh2ps5bwewmi
MAP QUERY TOOK: 4955000STRUCT QUERY FOUND: low4vvu5abdo2sh2ps5bwewmi
STRUCT QUERY TOOK: 1222000 (WIN)
```Many items, few history items (resp: 500000, max 15):
```
MAP QUERY FOUND: oe2fmjop1rql0etxj2974aemi
MAP QUERY TOOK: 34858000STRUCT QUERY FOUND: oe2fmjop1rql0etxj2974aemi
STRUCT QUERY TOOK: 5360000 (WIN)
```Few items, many history items (resp: 5, +/- 525960)
```
MAP QUERY FOUND: acipbh9dozyqrnjeam485gsyvi
MAP QUERY TOOK: 53729000STRUCT QUERY FOUND: acipbh9dozyqrnjeam485gsyvi
STRUCT QUERY TOOK: 1107000 (WIN)
```