Skip to content

Commit c6600d1

Browse files
sam-githubtargos
authored andcommitted
deps: upgrade http-parser to v2.9.1
PR-URL: #30473 Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
1 parent b69f2dd commit c6600d1

7 files changed

Lines changed: 310 additions & 198 deletions

File tree

‎deps/http_parser/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ HELPER ?=
2323
BINEXT ?=
2424
SOLIBNAME = libhttp_parser
2525
SOMAJOR = 2
26-
SOMINOR = 8
27-
SOREV = 0
26+
SOMINOR = 9
27+
SOREV = 1
2828
ifeq (darwin,$(PLATFORM))
2929
SOEXT ?= dylib
3030
SONAME ?= $(SOLIBNAME).$(SOMAJOR).$(SOMINOR).$(SOEXT)

‎deps/http_parser/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ callback in a threadsafe manner. This allows `http_parser` to be used in
148148
multi-threaded contexts.
149149

150150
Example:
151-
```
151+
```c
152152
typedefstruct {
153153
socket_t sock;
154154
void* buffer;
@@ -184,7 +184,7 @@ void http_parser_thread(socket_t sock) {
184184
parser supplied to callback functions */
185185
parser->data = my_data;
186186

187-
http_parser_settings settings; /* set up callbacks */
187+
http_parser_settings settings; /* set up callbacks */
188188
settings.on_url = my_url_callback;
189189

190190
/* execute parser */

‎deps/http_parser/bench.c‎

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
*/
2121
#include"http_parser.h"
2222
#include<assert.h>
23+
#include<stdint.h>
2324
#include<stdio.h>
2425
#include<string.h>
2526
#include<sys/time.h>
2627

28+
/* 8 gb */
29+
staticconstint64_tkBytes=8LL << 30;
30+
2731
staticconstchardata[] =
2832
"POST /joyent/http-parser HTTP/1.1\r\n"
2933
"Host: github.com\r\n"
@@ -38,7 +42,7 @@ static const char data[] =
3842
"Referer: https://github.com/joyent/http-parser\r\n"
3943
"Connection: keep-alive\r\n"
4044
"Transfer-Encoding: chunked\r\n"
41-
"Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n\r\n";
45+
"Cache-Control: max-age=0\r\n\r\nb\r\nhello world\r\n0\r\n";
4246
staticconstsize_tdata_len=sizeof(data) -1;
4347

4448
staticinton_info(http_parser*p) {
@@ -67,13 +71,13 @@ int bench(int iter_count, int silent) {
6771
interr;
6872
structtimevalstart;
6973
structtimevalend;
70-
floatrps;
7174

7275
if (!silent) {
7376
err=gettimeofday(&start, NULL);
7477
assert(err==0);
7578
}
7679

80+
fprintf(stderr, "req_len=%d\n", (int) data_len);
7781
for (i=0; i<iter_count; i++) {
7882
size_tparsed;
7983
http_parser_init(&parser, HTTP_REQUEST);
@@ -83,29 +87,42 @@ int bench(int iter_count, int silent) {
8387
}
8488

8589
if (!silent) {
90+
doubleelapsed;
91+
doublebw;
92+
doubletotal;
93+
8694
err=gettimeofday(&end, NULL);
8795
assert(err==0);
8896

8997
fprintf(stdout, "Benchmark result:\n");
9098

91-
rps= (float) (end.tv_sec-start.tv_sec) +
92-
(end.tv_usec-start.tv_usec) *1e-6f;
93-
fprintf(stdout, "Took %f seconds to run\n", rps);
99+
elapsed= (double) (end.tv_sec-start.tv_sec) +
100+
(end.tv_usec-start.tv_usec) *1e-6f;
101+
102+
total= (double) iter_count*data_len;
103+
bw= (double) total / elapsed;
104+
105+
fprintf(stdout, "%.2f mb | %.2f mb/s | %.2f req/sec | %.2f s\n",
106+
(double) total / (1024*1024),
107+
bw / (1024*1024),
108+
(double) iter_count / elapsed,
109+
elapsed);
94110

95-
rps= (float) iter_count / rps;
96-
fprintf(stdout, "%f req/sec\n", rps);
97111
fflush(stdout);
98112
}
99113

100114
return0;
101115
}
102116

103117
intmain(intargc, char**argv) {
118+
int64_titerations;
119+
120+
iterations=kBytes / (int64_t) data_len;
104121
if (argc==2&&strcmp(argv[1], "infinite") ==0) {
105122
for (;;)
106-
bench(5000000, 1);
123+
bench(iterations, 1);
107124
return0;
108125
} else {
109-
returnbench(5000000, 0);
126+
returnbench(iterations, 0);
110127
}
111128
}

0 commit comments

Comments
 (0)