FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node/benchmark/http/client-request-body.js at master · anchnk/node · GitHub
anchnk
/
node
Public
forked from
nodejs/node
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node
/
benchmark
/
http
/
client-request-body.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
70 lines (62 loc) · 1.43 KB
Breadcrumbs
node
/
benchmark
/
http
/
client-request-body.js
Copy path
File metadata and controls
70 lines (62 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Measure the time it takes for the HTTP client to send a request body.
'use strict'
;
var
common
=
require
(
'../common.js'
)
;
var
http
=
require
(
'http'
)
;
var
bench
=
common
.
createBenchmark
(
main
,
{
dur
:
[
5
]
,
type
:
[
'asc'
,
'utf'
,
'buf'
]
,
len
:
[
32
,
256
,
1024
]
,
method
:
[
'write'
,
'end'
]
}
)
;
function
main
(
conf
)
{
var
dur
=
+
conf
.
dur
;
var
len
=
+
conf
.
len
;
var
encoding
;
var
chunk
;
switch
(
conf
.
type
)
{
case
'buf'
:
chunk
=
Buffer
.
alloc
(
len
,
'x'
)
;
break
;
case
'utf'
:
encoding
=
'utf8'
;
chunk
=
'ü'
.
repeat
(
len
/
2
)
;
break
;
case
'asc'
:
chunk
=
'a'
.
repeat
(
len
)
;
break
;
}
var
nreqs
=
0
;
var
options
=
{
headers
:
{
'Connection'
:
'keep-alive'
,
'Transfer-Encoding'
:
'chunked'
}
,
agent
:
new
http
.
Agent
(
{
maxSockets
:
1
}
)
,
host
:
'127.0.0.1'
,
port
:
common
.
PORT
,
path
:
'/'
,
method
:
'POST'
}
;
var
server
=
http
.
createServer
(
function
(
req
,
res
)
{
res
.
end
(
)
;
}
)
;
server
.
listen
(
options
.
port
,
options
.
host
,
function
(
)
{
setTimeout
(
done
,
dur
*
1000
)
;
bench
.
start
(
)
;
pummel
(
)
;
}
)
;
function
pummel
(
)
{
var
req
=
http
.
request
(
options
,
function
(
res
)
{
nreqs
++
;
pummel
(
)
;
// Line up next request.
res
.
resume
(
)
;
}
)
;
if
(
conf
.
method
===
'write'
)
{
req
.
write
(
chunk
,
encoding
)
;
req
.
end
(
)
;
}
else
{
req
.
end
(
chunk
,
encoding
)
;
}
}
function
done
(
)
{
bench
.
end
(
nreqs
)
;
process
.
exit
(
0
)
;
}
}
Back
|
FazBrowse Home
|
New Git URL