Skip to content

Instantly share code, notes, and snippets.

@isaacs
Last active March 25, 2017 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/ce29ec1843992cd38d231ef87b5c78a9 to your computer and use it in GitHub Desktop.
Save isaacs/ce29ec1843992cd38d231ef87b5c78a9 to your computer and use it in GitHub Desktop.
# all times are in ms
# downloads.tar is my downloads folder, which is gigantic because i'm lazy
# and never delete anything out of it.
$ ls -laF downloads.tar
-rw-r--r-- 1 isaacs staff 6552657408 Mar 23 23:54 downloads.tar
# read synchronously and writes to an extractor that does all sync fs operations
$ node es-sync2.js downloads.tar
13734.368
# 13.7s, not bad
# the default async streaming extractor
$ node es.js downloads.tar
14273.495
# 14.3s. also good.
# tar-fs, the fastest tar parser on npm right now
$ node tf.js downloads.tar
29743.513
# ~30s. Hmm.. Acceptable.
# node-tar v1, what a stank trash pile who wrote this thing jeez
$ node old-extract.js downloads.tar
98606.987
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: ENOENT: no such file or directory, open '/Users/isaacs/dev/js/tar/test/extract/into/some/folder/Downloads/Spectacle.app/Contents/Frameworks/Sparkle.framework/Headers'
# UNACCEPTABLE!
# Just for comparison, this is the gold standard right here for tar handling, the
# incredibly fast and always correct bsdtar, let's see how it handles it...
$ time tar xf downloads.tar -C test/extract/into/some/folder/
real 0m16.920s
user 0m0.635s
sys 0m12.126s
# 17 seconds!? To be fair, that includes process startup, which the timers in
# my node programs excluded, so really, the 12.126s plus the 0.635s is the apples
# to apples comparison.
# That is, 12.75s
# So, the sync extractor is only 7.5% slower than tar(1), and the async streaming
# extractor is only 11.5% slower. (Compared with tar-fs at more than double, and
# node-tar 1.x at.. well, infinity slower, because it barfs.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment