Skip to content

Commit

Permalink
docs: adding benchmarks + instructions to README
Browse files Browse the repository at this point in the history
  • Loading branch information
ahashim committed Sep 24, 2022
1 parent 0f69aba commit 892ab6b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,33 @@ A data structure to stop the thundering herd 🐎🐎🐎
type PromiseMap<Key, Value> = Map<Key, Promise<Value>>
```
Cache expensive requests instead of their results.
## Benchmarks
* Install dependencies: `npm install`
* Run benchmarks: `npm benchmark`
```
Data
==============================================================
data: {
avatar: 'https://ahmedhashim.app/images/low_poly_avatar.png',
bio: 'definitely not a bot',
id: 1,
joined: 1663424830,
location: { latitude: -27.09962924203303, longitude: -109.34637304606693 },
username: 'ahmed'
}


Using an ordinary Map
==============================================================
requests: 50
cache misses: 50


Using a PromiseMap
==============================================================
requests: 50
cache misses: 1
```
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
],
"type": "module",
"scripts": {
"benchmark": "ts-node src/index.ts",
"compile": "tsc",
"prepare": "ts-node src/index.ts",
"watch": "nodemon src/index.ts"
"prepare": "npm run benchmark"
},
"devDependencies": {
"@types/node": "^14.11.2",
"gts": "^3.1.1",
"nodemon": "^2.0.20",
"ts-node": "^10.9.1",
"typescript": "~4.7.0"
}
Expand Down

0 comments on commit 892ab6b

Please sign in to comment.