Created
March 8, 2018 21:29
-
-
Save menduz/d4fd8caabee8b4f51cf2d4edada1521a to your computer and use it in GitHub Desktop.
Perf test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cp = require("child_process"); | |
const http = require("http"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const express = require("express"); | |
const tmpPath = path.resolve(__dirname, "tmpfile"); | |
const app = express(); | |
app.get("/", function(req, res, next) { | |
cp.execFile( | |
"ipfs", | |
[ | |
"get", | |
"--output=" + tmpPath, | |
"/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme" | |
], | |
function(err, stdout, stderr) { | |
const readStream = fs.createReadStream(tmpPath); | |
const stat = fs.statSync(tmpPath); | |
res.writeHead(200, "OK", { | |
"Content-Length": stat.size, | |
"Content-Type": "text/plain" | |
}); | |
readStream.pipe(res); | |
} | |
); | |
}); | |
app.listen(9615, function(err) { | |
console.log(err); | |
}); | |
/** | |
* ➜ pref-spawn ab -n 1000 -c 100 http://localhost:9615/ | |
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests | |
Completed 500 requests | |
Completed 600 requests | |
Completed 700 requests | |
Completed 800 requests | |
Completed 900 requests | |
Completed 1000 requests | |
Finished 1000 requests | |
Server Software: | |
Server Hostname: localhost | |
Server Port: 9615 | |
Document Path: / | |
Document Length: 1091 bytes | |
Concurrency Level: 100 | |
Time taken for tests: 12.108 seconds | |
Complete requests: 1000 | |
Failed requests: 2 | |
(Connect: 0, Receive: 0, Length: 2, Exceptions: 0) | |
Total transferred: 1234803 bytes | |
HTML transferred: 1088818 bytes | |
Requests per second: 82.59 [#/sec] (mean) | |
Time per request: 1210.780 [ms] (mean) | |
Time per request: 12.108 [ms] (mean, across all concurrent requests) | |
Transfer rate: 99.59 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 1.2 0 7 | |
Processing: 332 1183 231.8 1170 2323 | |
Waiting: 330 1160 214.5 1148 2278 | |
Total: 332 1184 231.9 1171 2324 | |
Percentage of the requests served within a certain time (ms) | |
50% 1171 | |
66% 1190 | |
75% 1208 | |
80% 1220 | |
90% 1237 | |
95% 1244 | |
98% 2217 | |
99% 2244 | |
100% 2324 (longest request) | |
➜ pref-spawn ab -n 1000 -c 100 http://localhost:9615/ | |
This is ApacheBench, Version 2.3 <$Revision: 1807734 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests | |
Completed 500 requests | |
Completed 600 requests | |
Completed 700 requests | |
Completed 800 requests | |
Completed 900 requests | |
Completed 1000 requests | |
Finished 1000 requests | |
Server Software: | |
Server Hostname: localhost | |
Server Port: 9615 | |
Document Path: / | |
Document Length: 1091 bytes | |
Concurrency Level: 100 | |
Time taken for tests: 12.390 seconds | |
Complete requests: 1000 | |
Failed requests: 4 | |
(Connect: 0, Receive: 0, Length: 4, Exceptions: 0) | |
Total transferred: 1232615 bytes | |
HTML transferred: 1086636 bytes | |
Requests per second: 80.71 [#/sec] (mean) | |
Time per request: 1238.963 [ms] (mean) | |
Time per request: 12.390 [ms] (mean, across all concurrent requests) | |
Transfer rate: 97.16 [Kbytes/sec] received | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 1.4 0 8 | |
Processing: 320 1214 225.4 1182 2314 | |
Waiting: 320 1164 206.8 1162 2275 | |
Total: 321 1215 225.4 1182 2315 | |
Percentage of the requests served within a certain time (ms) | |
50% 1182 | |
66% 1230 | |
75% 1235 | |
80% 1239 | |
90% 1406 | |
95% 1435 | |
98% 1988 | |
99% 2163 | |
100% 2315 (longest request) | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const express = require("express"); | |
const axios = require("axios"); | |
const tmpPath = path.resolve(__dirname, "tmpfile"); | |
const app = express(); | |
app.get("/", function(req, res, next) { | |
axios({ | |
method: "get", | |
url: | |
"http://localhost:8080/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme", | |
responseType: "stream" | |
}) | |
.then($ => { | |
res.writeHead(200, "OK", $.headers); | |
$.data.pipe(res); | |
}) | |
.catch($ => { | |
res.writeHead(500); | |
res.end(); | |
}); | |
}); | |
app.listen(9615, function(err) { | |
console.log(err); | |
}); | |
/* | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 0 0.9 0 5 | |
Processing: 41 81 16.4 80 120 | |
Waiting: 41 81 16.4 80 120 | |
Total: 46 82 16.0 80 120 | |
min mean[+/-sd] median max | |
Connect: 0 1 1.2 0 7 | |
Processing: 54 77 9.2 76 115 | |
Waiting: 54 77 9.2 76 115 | |
Total: 54 78 9.1 76 117 | |
min mean[+/-sd] median max | |
Connect: 0 1 1.3 0 7 | |
Processing: 36 70 10.9 73 91 | |
Waiting: 36 70 10.9 73 91 | |
Total: 42 71 10.3 73 91 | |
min mean[+/-sd] median max | |
Connect: 0 1 1.2 0 6 | |
Processing: 20 69 16.1 71 104 | |
Waiting: 20 69 16.1 71 104 | |
Total: 26 69 15.4 71 104 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const express = require("express"); | |
const axios = require("axios"); | |
const ipfsAPI = require("ipfs-api"); | |
var ipfs = ipfsAPI("/ip4/127.0.0.1/tcp/8080"); | |
const tmpPath = path.resolve(__dirname, "tmpfile"); | |
const app = express(); | |
app.get("/", function(req, res, next) { | |
ipfs.files.get( | |
"/ipfs/QmS4ustL54uo8FzR9455qaxZwuMiUhyvMcX9Ba8nUH4uVv/readme", | |
function(err, result) { | |
res.writeHead(200, "OK"); | |
res.write(result[0].content); | |
res.end(); | |
} | |
); | |
}); | |
app.listen(9615, function(err) { | |
console.log(err); | |
}); | |
/* | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 1.2 0 6 | |
Processing: 39 90 20.9 97 130 | |
Waiting: 39 90 21.0 97 130 | |
Total: 44 91 20.2 98 130 | |
Connection Times (ms) | |
min mean[+/-sd] median max | |
Connect: 0 1 1.2 0 12 | |
Processing: 25 93 23.4 97 143 | |
Waiting: 25 93 23.5 97 143 | |
Total: 30 94 23.0 97 143 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment