Skip to content

Commit

Permalink
chore: update README and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
poppinlp committed Jul 6, 2018
1 parent b39bfd1 commit 0f2c795
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 249 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ You may know [no-cache](https://github.com/helmetjs/nocache) as a [no-cache midd

You may find the reason in [benchmark result](./benchmarks/benchmark.txt) and wish you like it. :)

## Difference

This plugin has passed all [no-cache](https://github.com/helmetjs/nocache) test cases.
And no difference in options.

## Install

Via npm:
Expand Down
10 changes: 7 additions & 3 deletions benchmarks/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { writeFileSync } = require('fs');
const { EOL } = require('os');
const { EOL, platform, cpus } = require('os');
const { fork } = require('child_process');
const autocannon = require('autocannon');
const { host, port, path } = require('./config');
Expand Down Expand Up @@ -41,7 +41,7 @@ const test = name => new Promise((resolve, reject) => {
const sleep = time => new Promise(resolve => setTimeout(resolve, time));

const doCase = async name => {
const COUNT = 5;
const COUNT = 3;
const SLEEP = 3000;
const { desc } = caseMap[name];

Expand All @@ -57,7 +57,11 @@ const doCase = async name => {

(async () => {
const txt = [
'Average req/sec in 5 times 10s test',
`node version: ${process.version}`,
`platform: ${platform()}`,
`cpus: ${JSON.stringify(cpus())}`,
'',
'Average req/sec in 3 times 10s test',
await doCase('pure'),
await doCase('middleware'),
await doCase('plugin')
Expand Down
12 changes: 8 additions & 4 deletions benchmarks/benchmark.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Average req/sec in 5 times 10s test
with no plugin: 28357.30
with nocache middleware: 25900.59
with fastify-no-cache plugin: 27271.89
node version: v10.6.0
platform: darwin
cpus: [{"model":"Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz","speed":3100,"times":{"user":71055580,"nice":0,"sys":38365050,"idle":276525420,"irq":0}},{"model":"Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz","speed":3100,"times":{"user":38846960,"nice":0,"sys":16410360,"idle":330669350,"irq":0}},{"model":"Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz","speed":3100,"times":{"user":68535740,"nice":0,"sys":32351770,"idle":285039210,"irq":0}},{"model":"Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz","speed":3100,"times":{"user":39563970,"nice":0,"sys":15949530,"idle":330413150,"irq":0}}]

Average req/sec in 3 times 10s test
with no plugin: 24595.33
with nocache middleware: 18152.73
with fastify-no-cache plugin: 22588.47
Loading

0 comments on commit 0f2c795

Please sign in to comment.