Compare arrow function and bound function for:
- Memory usage
- Speed
- allocation
- invocation
Used for a talk:
Bind vs. Arrow Functions in Node.js
Outputs the memory usage of an arrow function
Outputs the memory usage of a bound function
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').
Creates a csv file speed_arrow_alloc.csv
containing invocation speed of an arrow function.
Creates a csv file speed_bind_alloc.csv
containing allocation speed of a bound function.
Creates a csv file speed_bind_alloc.csv
containing invocation speed of a bound function.
Outputs statistics for a given csv.
Argument
- [filename] {String} - name of the file
Example
hist.py speed_bind_alloc.csv
Required
- numpy
- Have nvm or n installed to run files in different node.js versions
- Run files and see the output.
- 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
- You might need
--harmony
flag for older version of node if you want to run files involving arrow functions.