merge slow-page-log into tracer, fixes #673

This commit is contained in:
Shish 2019-07-07 13:51:19 +01:00
parent 99646a4b00
commit 4cadce1de0
4 changed files with 8 additions and 20 deletions

View file

@ -108,8 +108,8 @@ function send_event(Event $event): void
$method_name = "on".str_replace("Event", "", get_class($event));
// send_event() is performance sensitive, and with the number
// of times context gets called the time starts to add up
$tracer_enabled = constant('EVENT_TRACE');
// of times tracer gets called the time starts to add up
$tracer_enabled = constant('TRACE_FILE');
if ($tracer_enabled) $_tracer->begin(get_class($event));
// SHIT: http://bugs.php.net/bug.php?id=35106

View file

@ -33,7 +33,6 @@ _d("DEBUG", false); // boolean print various debugging details
_d("DEBUG_SQL", false); // boolean dump SQL queries to data/sql.log
_d("DEBUG_CACHE", false); // boolean dump cache queries to data/cache.log
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
_d("EVENT_TRACE", null); // string file to log performance data into
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance
@ -47,7 +46,8 @@ _d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,set
_d("EXTRA_EXTS", ""); // string optional extra extensions
_d("BASE_URL", null); // string force a specific base URL (default is auto-detect)
_d("MIN_PHP_VERSION", '7.1');// string minimum supported PHP version
_d("SLOW_PAGES", null); // float log pages which take more time than this
_d("TRACE_FILE", null); // string file to log performance data into
_d("TRACE_THRESHOLD", 0.0); // float log pages which take more time than this many seconds
_d("ENABLED_MODS", "imageboard");
/*

View file

@ -390,19 +390,6 @@ function get_debug_info(): string
return $debug;
}
function log_slow(): void
{
global $_shm_load_start;
if (!is_null(SLOW_PAGES)) {
$_time = microtime(true) - $_shm_load_start;
if ($_time > SLOW_PAGES) {
$_query = _get_query();
$_dbg = get_debug_info();
file_put_contents("data/slow-pages.log", "$_time $_query $_dbg\n", FILE_APPEND | LOCK_EX);
}
}
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* Request initialisation stuff *

View file

@ -113,8 +113,9 @@ try {
_fatal_error($e);
}
log_slow();
$_tracer->end();
if (EVENT_TRACE) {
$_tracer->flush(EVENT_TRACE);
if (TRACE_FILE) {
if((microtime(true) - $_shm_load_start) > TRACE_THRESHOLD) {
$_tracer->flush(TRACE_FILE);
}
}