Add extra checking at the root of Log.Out to check if the category is subscribed to any of the output methods before trying to parse message strings and then pass them to the sub output functions and THEN perform log_setting checks and debug_level checks.

I performed a unit test of 1,000,000 log writes, there is hardly any difference.

#::: Before Checks
[01-25-2015 :: 03:15:35] [999999] Test #2... Took 17.940001 seconds

#::: With Checks
[01-25-2015 :: 04:10:55] [999999] Test #2... Took 18.018000 seconds
This commit is contained in:
Akkadius
2015-01-25 04:24:05 -06:00
parent 4f19fe9f91
commit 5266d7b25c
3 changed files with 12 additions and 14 deletions
+1 -10
View File
@@ -10472,19 +10472,10 @@ void command_logtest(Client *c, const Seperator *sep){
clock_t t = std::clock(); /* Function timer start */
if (sep->IsNumber(1)){
uint32 i = 0;
std::ofstream log_test;
for (i = 0; i < atoi(sep->arg[1]); i++){
log_test.open("logs/log_test.txt", std::ios_base::app | std::ios_base::out);
log_test << "this is a test\n";
log_test.close();
}
Log.Out(Logs::General, Logs::Zone_Server, "[%u] Test #1... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
t = std::clock();
log_test.open("logs/log_test.txt", std::ios_base::app | std::ios_base::out);
for (i = 0; i < atoi(sep->arg[1]); i++){
Log.Out(Logs::General, Logs::Zone_Server, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
Log.Out(Logs::General, Logs::Debug, "[%u] Test #2... Took %f seconds", i, ((float)(std::clock() - t)) / CLOCKS_PER_SEC);
}
log_test.close();
}
}