Tested timing between printf and cout. cout won by a mile.

This commit is contained in:
2026-05-29 11:17:13 -04:00
parent 0e9a04a701
commit 2bceb55cf2
2 changed files with 4 additions and 25 deletions

View File

@@ -4,6 +4,7 @@
#include <string>
#include <vector>
#include <regex>
#include <chrono>
#include "log_parsing.hpp"
@@ -92,7 +93,7 @@ std::string p_logs::entryx_browser(int x){
// TO DO: TIME THE DIFFERENCE BETWEEN THESE TWO PRINTING METHODS
void p_logs::print_logs() {
// Simple printing
std::ios_base::sync_with_stdio(false);
for (const auto& log : logs) {
std::cout << "IP: " << log.ip.c_str() << "\n"
<< "Timestamp: " << log.timestamp.c_str() << "\n"
@@ -105,27 +106,5 @@ void p_logs::print_logs() {
<< "-----------------------------\n\n";
}
// Faster Printing?
for (const auto& log : logs) {
std::printf(
"IP: %s\n"
"Timestamp: %s\n"
"Request: %s\n"
"Status: %s\n"
"Bytes: %s\n"
"Referer: %s\n"
"OS: %s\n"
"Browser: %s\n\n"
"-----------------------------\n\n",
log.ip.c_str(),
log.timestamp.c_str(),
log.request.c_str(),
log.status.c_str(),
log.bytes.c_str(),
log.referer.c_str(),
log.os.c_str(),
log.browser.c_str()
);
}
std::cout.flush();
}

Binary file not shown.