MCPcopy Create free account
hub / github.com/NatronGitHub/Natron / bench

Function bench

libs/qhttpserver/http-parser/bench.c:64–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62};
63
64int bench(int iter_count, int silent) {
65 struct http_parser parser;
66 int i;
67 int err;
68 struct timeval start;
69 struct timeval end;
70 float rps;
71
72 if (!silent) {
73 err = gettimeofday(&start, NULL);
74 assert(err == 0);
75 }
76
77 for (i = 0; i < iter_count; i++) {
78 size_t parsed;
79 http_parser_init(&parser, HTTP_REQUEST);
80
81 parsed = http_parser_execute(&parser, &settings, data, data_len);
82 assert(parsed == data_len);
83 }
84
85 if (!silent) {
86 err = gettimeofday(&end, NULL);
87 assert(err == 0);
88
89 fprintf(stdout, "Benchmark result:\n");
90
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);
94
95 rps = (float) iter_count / rps;
96 fprintf(stdout, "%f req/sec\n", rps);
97 fflush(stdout);
98 }
99
100 return 0;
101}
102
103int main(int argc, char** argv) {
104 if (argc == 2 && strcmp(argv[1], "infinite") == 0) {

Callers 1

mainFunction · 0.85

Calls 3

http_parser_initFunction · 0.85
http_parser_executeFunction · 0.85
gettimeofdayFunction · 0.50

Tested by

no test coverage detected