Skip to content

Instantly share code, notes, and snippets.

@wodCZ
Created March 17, 2020 18:47
Show Gist options
  • Select an option

  • Save wodCZ/d54422bee3a06bf5048973a40cd9f28c to your computer and use it in GitHub Desktop.

Select an option

Save wodCZ/d54422bee3a06bf5048973a40cd9f28c to your computer and use it in GitHub Desktop.

Revisions

  1. wodCZ created this gist Mar 17, 2020.
    53 changes: 53 additions & 0 deletions express.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    const express = require('express')
    const app = express()
    const port = 4000

    app.get('/', (req, res) => res.send('Hello World!'))

    app.listen(port, () => console.log(`Example app listening on port ${port}!`))

    // node express.js

    /*
    /\ |‾‾| /‾‾/ /‾/
    /\ / \ | |_/ / / /
    / \/ \ | | / ‾‾\
    / \ | |‾\ \ | (_) |
    / __________ \ |__| \__\ \___/ .io
    execution: local--------------------------------------------------] servertor
    output: -
    script: -
    duration: 10s, iterations: -
    vus: 30, max: 30
    time="2020-03-17T18:43:46Z" level=info msg=Running i=2981 t=955.5863msstarting
    time="2020-03-17T18:43:47Z" level=info msg=Running i=6792 t=1.9669787s
    time="2020-03-17T18:43:48Z" level=info msg=Running i=11514 t=2.9619078s
    time="2020-03-17T18:43:49Z" level=info msg=Running i=16089 t=3.9673322s
    time="2020-03-17T18:43:50Z" level=info msg=Running i=20744 t=4.9627029s
    time="2020-03-17T18:43:51Z" level=info msg=Running i=25548 t=5.9554418s
    time="2020-03-17T18:43:52Z" level=info msg=Running i=30668 t=6.9669815s
    time="2020-03-17T18:43:53Z" level=info msg=Running i=35639 t=7.9609981s
    time="2020-03-17T18:43:54Z" level=info msg=Running i=39840 t=8.9664527s
    time="2020-03-17T18:43:55Z" level=info msg=Running i=45099 t=9.9498675s
    time="2020-03-17T18:43:55Z" level=info msg="Test finished" i=45215 t=10.0061199s
    data_received..............: 9.8 MB 976 kB/s
    data_sent..................: 3.8 MB 380 kB/s
    http_req_blocked...........: avg=61.04µs min=0s med=34.5µs max=17.32ms p(90)=86.6µs p(95)=141.8µs
    http_req_connecting........: avg=2.83µs min=0s med=0s max=7.11ms p(90)=0s p(95)=0s
    http_req_duration..........: avg=3.5ms min=71.9µs med=3.12ms max=37.26ms p(90)=5.94ms p(95)=7.4ms
    http_req_receiving.........: avg=140.24µs min=41.3µs med=82.7µs max=33.34ms p(90)=220.6µs p(95)=317.31µs
    http_req_sending...........: avg=71.97µs min=16.8µs med=36.7µs max=26.57ms p(90)=111.3µs p(95)=171.8µs
    http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
    http_req_waiting...........: avg=3.28ms min=0s med=2.94ms max=29.59ms p(90)=5.68ms p(95)=7.06ms
    http_reqs..................: 45238 4521.033173/s
    iteration_duration.........: avg=3.87ms min=580.1µs med=3.46ms max=37.51ms p(90)=6.4ms p(95)=7.96ms
    iterations.................: 45238 4521.033173/s
    vus........................: 30 min=30 max=30
    vus_max....................: 30 min=30 max=30
    */
    53 changes: 53 additions & 0 deletions fastapi.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    from fastapi import FastAPI

    app = FastAPI()


    @app.get("/")
    async def root():
    return {"message": "Hello World"}

    # uvicorn main:app --host 0.0.0.0 --workers 2 --no-access-log

    """
    /\ |‾‾| /‾‾/ /‾/
    /\ / \ | |_/ / / /
    / \/ \ | | / ‾‾\
    / \ | |‾\ \ | (_) |
    / __________ \ |__| \__\ \___/ .io
    execution: local--------------------------------------------------] servertor
    output: -
    script: -
    duration: 10s, iterations: -
    vus: 30, max: 30
    time="2020-03-17T18:41:14Z" level=info msg=Running i=4033 t=971.8764msstarting
    time="2020-03-17T18:41:15Z" level=info msg=Running i=8211 t=1.9674108s
    time="2020-03-17T18:41:16Z" level=info msg=Running i=13212 t=2.961034s
    time="2020-03-17T18:41:17Z" level=info msg=Running i=17749 t=3.9749847s
    time="2020-03-17T18:41:18Z" level=info msg=Running i=22653 t=4.9712233s
    time="2020-03-17T18:41:19Z" level=info msg=Running i=27476 t=5.9624155s
    time="2020-03-17T18:41:20Z" level=info msg=Running i=32148 t=6.9568929s
    time="2020-03-17T18:41:21Z" level=info msg=Running i=36873 t=7.9722637s
    time="2020-03-17T18:41:22Z" level=info msg=Running i=41220 t=8.9699711s
    time="2020-03-17T18:41:23Z" level=info msg=Running i=46279 t=9.9712915s
    time="2020-03-17T18:41:23Z" level=info msg="Test finished" i=46394 t=10.0021554s
    data_received..............: 7.0 MB 696 kB/s
    data_sent..................: 3.9 MB 390 kB/s
    http_req_blocked...........: avg=54.23µs min=21.7µs med=34.2µs max=25.56ms p(90)=70.6µs p(95)=123.9µs
    http_req_connecting........: avg=2.83µs min=0s med=0s max=6.28ms p(90)=0s p(95)=0s
    http_req_duration..........: avg=4.11ms min=588µs med=3.84ms max=42.21ms p(90)=6.44ms p(95)=7.52ms
    http_req_receiving.........: avg=129.01µs min=40.2µs med=79.5µs max=24.99ms p(90)=196µs p(95)=276µs
    http_req_sending...........: avg=64.83µs min=17.2µs med=35.8µs max=18.73ms p(90)=95.1µs p(95)=144.8µs
    http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
    http_req_waiting...........: avg=3.92ms min=474.5µs med=3.67ms max=40.98ms p(90)=6.21ms p(95)=7.24ms
    http_reqs..................: 46401 4639.100088/s
    iteration_duration.........: avg=4.45ms min=862.2µs med=4.14ms max=54.83ms p(90)=6.84ms p(95)=7.98ms
    iterations.................: 46401 4639.100088/s
    vus........................: 30 min=30 max=30
    vus_max....................: 30 min=30 max=30
    """
    76 changes: 76 additions & 0 deletions hapi.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,76 @@
    'use strict';

    const Hapi = require('@hapi/hapi');

    const init = async () => {

    const server = Hapi.server({
    port: 3000,
    host: '0.0.0.0'
    });

    server.route({
    method: 'GET',
    path: '/',
    handler: (request, h) => {
    return 'Hello World!';
    }
    })

    await server.start();
    console.log('Server running on %s', server.info.uri);
    };

    process.on('unhandledRejection', (err) => {

    console.log(err);
    process.exit(1);
    });

    init();

    // node index.js

    /*
    /\ |‾‾| /‾‾/ /‾/
    /\ / \ | |_/ / / /
    / \/ \ | | / ‾‾\
    / \ | |‾\ \ | (_) |
    / __________ \ |__| \__\ \___/ .io
    execution: local--------------------------------------------------] servertor
    output: -
    script: -
    duration: 10s, iterations: -
    vus: 30, max: 30
    time="2020-03-17T18:41:42Z" level=info msg=Running i=3615 t=988.9855msstarting
    time="2020-03-17T18:41:43Z" level=info msg=Running i=8387 t=1.9797251s
    time="2020-03-17T18:41:44Z" level=info msg=Running i=13107 t=2.9719291s
    time="2020-03-17T18:41:45Z" level=info msg=Running i=18678 t=4.1168958s
    time="2020-03-17T18:41:46Z" level=info msg=Running i=22604 t=4.9677587s
    time="2020-03-17T18:41:47Z" level=info msg=Running i=28008 t=5.9638922s
    time="2020-03-17T18:41:48Z" level=info msg=Running i=32946 t=6.9718871s
    time="2020-03-17T18:41:49Z" level=info msg=Running i=37574 t=7.9679537s
    time="2020-03-17T18:41:50Z" level=info msg=Running i=41780 t=8.975196s
    time="2020-03-17T18:41:51Z" level=info msg=Running i=47241 t=9.9619773s
    time="2020-03-17T18:41:51Z" level=info msg="Test finished" i=47311 t=10.0009758s
    data_received..............: 9.4 MB 942 kB/s
    data_sent..................: 4.0 MB 398 kB/s
    http_req_blocked...........: avg=59.73µs min=24µs med=33.8µs max=18.48ms p(90)=84µs p(95)=137.65µs
    http_req_connecting........: avg=2.58µs min=0s med=0s max=7.92ms p(90)=0s p(95)=0s
    http_req_duration..........: avg=3.3ms min=415.5µs med=3.02ms max=22.28ms p(90)=5.49ms p(95)=6.6ms
    http_req_receiving.........: avg=129.43µs min=40.1µs med=80.3µs max=16.22ms p(90)=214.4µs p(95)=309.5µs
    http_req_sending...........: avg=68.49µs min=15.5µs med=35.4µs max=14.12ms p(90)=105µs p(95)=165.5µs
    http_req_tls_handshaking...: avg=0s min=0s med=0s max=0s p(90)=0s p(95)=0s
    http_req_waiting...........: avg=3.1ms min=333.3µs med=2.84ms max=21.76ms p(90)=5.26ms p(95)=6.32ms
    http_reqs..................: 47330 4732.538199/s
    iteration_duration.........: avg=3.66ms min=575.6µs med=3.34ms max=26.25ms p(90)=5.89ms p(95)=7.09ms
    iterations.................: 47330 4732.538199/s
    vus........................: 30 min=30 max=30
    vus_max....................: 30 min=30 max=30
    */