-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathragel_performance.cc
42 lines (37 loc) · 1.02 KB
/
ragel_performance.cc
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
/*
* parser_performance.cc
*
* Created on: Feb 19, 2012
* Author: liangxu
*/
#include <stdint.h>
#include <string>
#include <gtest/gtest.h>
#include "ragel/http11_parser.h"
#include "defines.h"
TEST(ParserPerformance, ragel_dump) {
http_parser_settings settings_dump = {
on_message_begin_dump,
on_url_dump,
on_header_field_dump,
on_header_value_dump,
on_headers_complete_dump,
on_body_dump,
on_message_complete_dump
};
http_parser parser;
ragel_http_parser_init(&parser, HTTP_REQUEST);
ASSERT_EQ(kMessage.size(),
ragel_http_parser_execute(&parser, &settings_dump, kMessage.c_str(),
kMessage.size()));
printf("method: %s\n", http_method_str((http_method)parser.method));
}
TEST(ParserPerformance, ragel) {
http_parser_settings settings_null = {};
http_parser parser;
for (uint32_t i = 0; i < kLoop; ++i) {
ragel_http_parser_init(&parser, HTTP_REQUEST);
ragel_http_parser_execute(&parser, &settings_null, kMessage.c_str(),
kMessage.size());
}
}