Skip to content

Commit fa4bab8

Browse files
committed
simplify running applications without logging messages for every HTTP request
1 parent 1bb635f commit fa4bab8

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,13 @@ Windows 10 Version 21H1 (Build 19043.1645)
185185
Number of HTTP server threads: 8
186186
Logging of every request is disabled for both server and client side.
187187

188+
Starting applications without logging messages for every HTTP request:
189+
190+
```bash
191+
WebServer.exe --no-logs
192+
Client.exe --no-logs
193+
```
194+
188195
### Results
189196

190197
| Number of <br/>request threads | 10K requests <br/>per thread, req/sec | 100K requests <br/>per thread, req/sec |

client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import http.client
55
import multiprocessing
66
import random
7+
import sys
78
import time
89
import urllib.parse
910

@@ -27,7 +28,9 @@
2728

2829
PERCENT_OF_WRITES = 1
2930

30-
LOG_EVERY_REQUEST = True
31+
arg1 = sys.argv[1] if len(sys.argv) > 1 else ''
32+
33+
LOG_EVERY_REQUEST = arg1 != '--no-logs'
3134

3235
# =======================================
3336

main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@
1111
#include <thread>
1212

1313

14-
int main(void)
14+
int main(const int argc, const char * const * const argv)
1515
{
1616
LOG_INFO << "main: begin" << std::endl;
17+
const std::string arg1 = argc > 1 ? argv[1] : "";
1718

1819
// =========================================================
1920
// === Configuration:
2021
// =========================================================
2122

2223
const std::string listenHost = "127.0.0.1";
2324
const std::uint16_t listenPort = 8000;
24-
const std::string databaseFilename = "database.json";
25-
const bool logEachRequest = true;
25+
const std::string databaseFilename = "database.json";
26+
const bool logEachRequest = arg1 != "--no-logs";
2627

2728
// =========================================================
2829

0 commit comments

Comments
 (0)