Skip to content

Instantly share code, notes, and snippets.

@hex7c0
Created January 26, 2015 20:15
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 hex7c0/25165f2f4650dfe16832 to your computer and use it in GitHub Desktop.
Save hex7c0/25165f2f4650dfe16832 to your computer and use it in GitHub Desktop.
compression with zilb options
// iojs@1.0.4
// express@4.11.1
// compression@1.3.0
file = require('fs').readFileSync('s.cc') // 46Kb
zlib = require('zlib')
app = require('express')()
compression = require('compression')
app.get('/no_compression', function(req, res){
res.setHeader('Content-Type','text/plain')
res.send(file)
}).get('/with_compression', compression(), function(req, res){
res.setHeader('Content-Type','text/plain')
res.send(file)
}).get('/with_level_compression', compression({level: zlib.Z_BEST_SPEED, memLevel: zlib.Z_MAX_MEMLEVEL}), function(req, res){
res.setHeader('Content-Type','text/plain')
res.send(file)
}).listen(3000)
$ ab -H "Accept-Encoding: gzip" -c 100 -n 5000 192.168.2.2:3000/no_compression
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software:
Server Hostname: 192.168.2.2
Server Port: 3000
Document Path: /no_compression
Document Length: 46155 bytes
Concurrency Level: 100
Time taken for tests: 4.830 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 231690000 bytes
HTML transferred: 230775000 bytes
Requests per second: 1035.30 [#/sec] (mean)
Time per request: 96.590 [ms] (mean)
Time per request: 0.966 [ms] (mean, across all concurrent requests)
Transfer rate: 46849.52 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 12 15.6 8 217
Processing: 3 79 140.7 42 1301
Waiting: 0 28 60.9 16 909
Total: 6 91 141.3 54 1308
$ ab -H "Accept-Encoding: gzip" -c 100 -n 5000 192.168.2.2:3000/with_compression
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software:
Server Hostname: 192.168.2.2
Server Port: 3000
Document Path: /with_compression
Document Length: 14105 bytes
Concurrency Level: 100
Time taken for tests: 6.635 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 71560000 bytes
HTML transferred: 70525000 bytes
Requests per second: 753.60 [#/sec] (mean)
Time per request: 132.697 [ms] (mean)
Time per request: 1.327 [ms] (mean, across all concurrent requests)
Transfer rate: 10532.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 5.0 2 146
Processing: 20 126 107.0 104 973
Waiting: 3 77 59.3 74 939
Total: 23 129 107.1 107 974
$ ab -H "Accept-Encoding: gzip" -c 100 -n 5000 192.168.2.2:3000/with_level_compression
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Server Software:
Server Hostname: 192.168.2.2
Server Port: 3000
Document Path: /with_level_compression
Document Length: 16481 bytes
Concurrency Level: 100
Time taken for tests: 5.028 seconds
Complete requests: 5000
Failed requests: 0
Write errors: 0
Total transferred: 83440000 bytes
HTML transferred: 82405000 bytes
Requests per second: 994.36 [#/sec] (mean)
Time per request: 100.567 [ms] (mean)
Time per request: 1.006 [ms] (mean, across all concurrent requests)
Transfer rate: 16204.94 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 4 4.4 2 44
Processing: 13 96 81.1 80 575
Waiting: 7 51 28.1 49 484
Total: 23 100 81.5 83 593
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment