Skip to content

Commit

Permalink
Shift feet from Q to Promise.prototype
Browse files Browse the repository at this point in the history
This puts primary implementations of all methods onto the promise
prototype.  Instead of channeling all of the interface through as few
functions as possible, passes all implementations through as few stack
frames as possible.  Both Q and Promise.prototype implementations are
unrolled.

This should improve performance in various ways.  For one, we do not
need to check or coerce the source promise if we're being called as a
prototype method.

Since we do not have a benchmarking system of any appreciable
sophistication, I will refrain from posting any numbers, but the speed
of running our test suite does not change significantly.

Unrolling the prototype methods does increase code size but increases
redundancy.  The minified size increases by 2kb and the gzip size increases by
about 200 bytes.

Before:
    Original: 53148 bytes.
    Minified: 12245 bytes.
    Gzipped:  2535 bytes.
After:
    Original: 56478 bytes.
    Minified: 14254 bytes.
    Gzipped:  2725 bytes.

Although we are no longer generating prototype methods from a list of names of
methods on the Q object, the code coverage did not change significantly.  Our
report shows 90% both before and after.
  • Loading branch information
kriskowal committed Jul 7, 2013
1 parent d144e13 commit e686c9d
Show file tree
Hide file tree
Showing 2 changed files with 366 additions and 271 deletions.
Loading

0 comments on commit e686c9d

Please sign in to comment.