Skip to Content
Node Cookbook - Third Edition
book

Node Cookbook - Third Edition

by Matteo Collina, David Mark Clements, Peter Elger, Mathias Buus Madsen
July 2017
Intermediate to advanced
656 pages
16h 1m
English
Packt Publishing
Content preview from Node Cookbook - Third Edition

Function inlining

In the main recipe we learned where our logic was spending a lot of time, and solved the problem by removing the overhead of one approach by replacing code with a lower impact alternative (the for loop).

Let's see if we can make the function faster.

We'll start by creating a new folder called function-inlining, then copy our no-collections.js and bench.js files into it:

$ mkdir function-inlining$ cp no-collection.js function-inlining$ cp bench.js function-inlining/initial-bench.js  

As we copied our bench.js file into function-inlining we also renamed it to initial-bench since we're starting a new optimization cycle.

We need to modify function-inlining/initial-bench.js by removing the slow benchmarks, leaving only our latest ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Node Cookbook - Fourth Edition

Node Cookbook - Fourth Edition

Bethany Griggs
Your First Week With Node.js, 2nd Edition

Your First Week With Node.js, 2nd Edition

James Hibbard, Craig Buckler, Mark Brown, Nilson Jacques, James Kolce, Paul Orac, M. David Green, Florian Rappl

Publisher Resources

ISBN: 9781785880087Supplemental Content