Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
parser_perf.cpp File Reference
#include <websocketpp/http/parser.hpp>
#include <chrono>
Include dependency graph for parser_perf.cpp:

Go to the source code of this file.

Classes

class  scoped_timer
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( void )

Definition at line 56 of file parser_perf.cpp.

56 {
57 std::string raw = "GET / HTTP/1.1\r\nHost: www.example.com\r\n\r\n";
58
59 std::string firefox = "GET / HTTP/1.1\r\nHost: localhost:5000\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0) Gecko/20100101 Firefox/10.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\nConnection: keep-alive, Upgrade\r\nSec-WebSocket-Version: 8\r\nSec-WebSocket-Origin: http://zaphoyd.com\r\nSec-WebSocket-Key: pFik//FxwFk0riN4ZiPFjQ==\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nUpgrade: websocket\r\n\r\n";
60
61 std::string firefox1 = "GET / HTTP/1.1\r\nHost: localhost:5000\r\nUser-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:10.0) Gecko/20100101 Firefox/10.0\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-us,en;q=0.5\r\n";
62
63 std::string firefox2 = "Accept-Encoding: gzip, deflate\r\nConnection: keep-alive, Upgrade\r\nSec-WebSocket-Version: 8\r\nSec-WebSocket-Origin: http://zaphoyd.com\r\nSec-WebSocket-Key: pFik//FxwFk0riN4ZiPFjQ==\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nUpgrade: websocket\r\n\r\n";
64
65 {
66 scoped_timer timer("Simplest 1 chop");
67 for (int i = 0; i < 1000; i++) {
69
70 try {
71 r.consume(raw.c_str(),raw.size());
72 } catch (...) {
73 std::cout << "exception" << std::endl;
74 }
75
76 if (!r.ready()) {
77 std::cout << "error" << std::endl;
78 break;
79 }
80 }
81 }
82
83 {
84 scoped_timer timer("FireFox, 1 chop, consume old");
85 for (int i = 0; i < 1000; i++) {
87
88 try {
89 r.consume2(firefox.c_str(),firefox.size());
90 } catch (...) {
91 std::cout << "exception" << std::endl;
92 }
93
94 if (!r.ready()) {
95 std::cout << "error" << std::endl;
96 break;
97 }
98 }
99 }
100
101 {
102 scoped_timer timer("FireFox, 1 chop");
103 for (int i = 0; i < 1000; i++) {
105
106 try {
107 r.consume(firefox.c_str(),firefox.size());
108 } catch (...) {
109 std::cout << "exception" << std::endl;
110 }
111
112 if (!r.ready()) {
113 std::cout << "error" << std::endl;
114 break;
115 }
116 }
117 }
118
119
120
121 {
122 scoped_timer timer("FireFox, 2 chop");
123 for (int i = 0; i < 1000; i++) {
125
126 try {
127 r.consume(firefox1.c_str(),firefox1.size());
128 r.consume(firefox2.c_str(),firefox2.size());
129 } catch (...) {
130 std::cout << "exception" << std::endl;
131 }
132
133 if (!r.ready()) {
134 std::cout << "error" << std::endl;
135 break;
136 }
137 }
138 }
139
140 return 0;
141}
const mie::Vuint & r
Definition bn.cpp:28
Stores, parses, and manipulates HTTP requests.
Definition request.hpp:50