Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sungwoncho/bind_vs_arrow
https://github.com/sungwoncho/bind_vs_arrow
Last synced: 15 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sungwoncho/bind_vs_arrow
- Owner: sungwoncho
- License: mit
- Created: 2017-04-01T08:07:26.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-04-06T12:08:05.000Z (over 7 years ago)
- Last Synced: 2024-10-19T17:27:07.921Z (3 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Arrow function vs bound function
Compare arrow function and bound function for:
* Memory usage
* Speed
* allocation
* invocationUsed for a talk:
[Bind vs. Arrow Functions in Node.js](https://sungwoncho.github.io/presentations/20170406-bind-vs-lambda.html#/)
## Files
### size_arrow.js
Outputs the memory usage of an arrow function
### size_bind.js
Outputs the memory usage of a bound function
### speed_arrow_alloc.js
Creates a csv file `speed_arrow_alloc.csv` containing allocation speed of an arrow function.
Feed the csv file to `hist.py` to get the statistics ('min,' 'max,' 'mean,' 'standard deviation').
### speed_arrow_invocation.js
Creates a csv file `speed_arrow_alloc.csv` containing invocation speed of an arrow function.
### speed_bind_alloc.js
Creates a csv file `speed_bind_alloc.csv` containing allocation speed of a bound function.
### speed_bind_invocation.js
Creates a csv file `speed_bind_alloc.csv` containing invocation speed of a bound function.
### hist.py
Outputs statistics for a given csv.
**Argument**
* [filename] {String} - name of the file
**Example**
hist.py speed_bind_alloc.csv
**Required**
* numpy
## Try
1. Have [nvm](https://github.com/creationix/nvm) or [n](https://github.com/tj/n) installed to run files in different node.js versions
2. Run files and see the output.
3. For files that output csv files, feed the csv file to `hist.py`. e.g.
node speed_arrow_alloc.js && python3 hist.py speed_arrow_alloc.csv && node speed_bind_alloc.js && python3 hist.py speed_bind_alloc.csv## Tip
* You might need `--harmony` flag for older version of node if you want to run files involving arrow functions.
---
[sung](https://sungwoncho.io)