Tested timing between printf and cout. cout won by a mile.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "log_parsing.hpp"
|
#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
|
// TO DO: TIME THE DIFFERENCE BETWEEN THESE TWO PRINTING METHODS
|
||||||
void p_logs::print_logs() {
|
void p_logs::print_logs() {
|
||||||
|
|
||||||
// Simple printing
|
std::ios_base::sync_with_stdio(false);
|
||||||
for (const auto& log : logs) {
|
for (const auto& log : logs) {
|
||||||
std::cout << "IP: " << log.ip.c_str() << "\n"
|
std::cout << "IP: " << log.ip.c_str() << "\n"
|
||||||
<< "Timestamp: " << log.timestamp.c_str() << "\n"
|
<< "Timestamp: " << log.timestamp.c_str() << "\n"
|
||||||
@@ -105,27 +106,5 @@ void p_logs::print_logs() {
|
|||||||
<< "-----------------------------\n\n";
|
<< "-----------------------------\n\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
std::cout.flush();
|
||||||
// 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()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
BIN
parselog_cli.exe
BIN
parselog_cli.exe
Binary file not shown.
Reference in New Issue
Block a user