File tree 4 files changed +1312
-0
lines changed
4 files changed +1312
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const autocannon = require ( 'autocannon' ) ;
4
+
5
+ async function main ( ) {
6
+ const result = await autocannon ( {
7
+ url : 'http://localhost:3000' ,
8
+ connections : 10 ,
9
+ duration : 120 ,
10
+ } )
11
+ console . log ( autocannon . printResult ( result ) ) ;
12
+ }
13
+
14
+ main ( ) ;
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const express = require ( 'express' ) ;
4
+ const pkgJson = require ( '../package.json' ) ;
5
+
6
+ if ( ! process . env . NSOLID_SAAS && ! hasPkgJsonConf ( ) ) {
7
+ console . error ( 'You forgot to pass NSOLID_SAAS environment variable.' ) ;
8
+ process . exit ( 1 ) ;
9
+ }
10
+
11
+ const app = express ( ) ;
12
+
13
+ app . get ( '/' , ( req , res ) => {
14
+ res . send ( { name : name ( ) } ) ;
15
+ } ) ;
16
+
17
+ app . listen ( 3000 , ( ) => {
18
+ console . log ( 'Server is running on port 3000' ) ;
19
+ console . info ( '🛈 In a separate terminal run: node benchmark.js' ) ;
20
+ } ) ;
21
+
22
+ const namesGenerator = require ( 'docker-namesgenerator' ) ;
23
+ const names = { } ;
24
+
25
+ function name ( ) {
26
+ let result = namesGenerator ( ) ;
27
+ if ( names [ result ] ) {
28
+ result += names [ result ] ++ ;
29
+ }
30
+ names [ result ] = 1 ;
31
+ return result ;
32
+ }
33
+
34
+ function hasPkgJsonConf ( ) {
35
+ return pkgJson . nsolid && pkgJson . nsolid . saas !== '' ;
36
+ }
You can’t perform that action at this time.
0 commit comments