1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-26 05:32:59 +00:00

Added size + decode time for major indexes

This commit is contained in:
Starbeamrainbowlabs 2016-08-20 11:27:26 +01:00
parent 75cb609b82
commit 6c4c00b156
5 changed files with 54 additions and 12 deletions

View file

@ -316,6 +316,7 @@ $env->user = "Anonymous";
$env->is_logged_in = false; $env->is_logged_in = false;
$env->is_admin = false; $env->is_admin = false;
$env->storage_prefix = $settings->data_storage_dir . DIRECTORY_SEPARATOR; $env->storage_prefix = $settings->data_storage_dir . DIRECTORY_SEPARATOR;
$env->perfdata = new stdClass();
/// Paths /// /// Paths ///
$paths = new stdClass(); $paths = new stdClass();
$paths->pageindex = "pageindex.json"; // The pageindex $paths->pageindex = "pageindex.json"; // The pageindex
@ -867,7 +868,8 @@ else
{ {
$pageindex_read_start = microtime(true); $pageindex_read_start = microtime(true);
$pageindex = json_decode(file_get_contents($paths->pageindex)); $pageindex = json_decode(file_get_contents($paths->pageindex));
header("x-pageindex-decode-time: " . round((microtime(true) - $pageindex_read_start)*1000, 3) . "ms"); $env->perfdata->pageindex_decode_time = round((microtime(true) - $pageindex_read_start)*1000, 3);
header("x-pageindex-decode-time: " . $env->perfdata->pageindex_decode_time . "ms");
} }
////////////////////////// //////////////////////////
@ -875,7 +877,9 @@ else
////////////////////////// //////////////////////////
if(!file_exists($paths->idindex)) if(!file_exists($paths->idindex))
file_put_contents($paths->idindex, "{}"); file_put_contents($paths->idindex, "{}");
$idindex_decode_start = microtime(true);
$idindex = json_decode(file_get_contents($paths->idindex)); $idindex = json_decode(file_get_contents($paths->idindex));
$env->perfdata->idindex_decode_time = round((microtime(true) - $idindex_decode_start)*1000, 3);
class ids class ids
{ {
/* /*
@ -2393,6 +2397,14 @@ class search
return $invindex; return $invindex;
} }
public static function measure_invindex_load_time($invindex_filename) {
global $env;
$searchindex_decode_start = microtime(true);
search::load_invindex($invindex_filename);
$env->perfdata->searchindex_decode_time = round((microtime(true) - $searchindex_decode_start)*1000, 3);
}
/* /*
* @summary Merge an index into an inverted index. * @summary Merge an index into an inverted index.
*/ */
@ -3944,7 +3956,7 @@ register_module([
* ██ ██ ███████ ███████ ██ * ██ ██ ███████ ███████ ██
*/ */
add_action("help", function() { add_action("help", function() {
global $paths, $settings, $version, $help_sections, $actions; global $env, $paths, $settings, $version, $help_sections, $actions;
// Sort the help sections by key // Sort the help sections by key
ksort($help_sections, SORT_NATURAL); ksort($help_sections, SORT_NATURAL);
@ -3971,8 +3983,17 @@ register_module([
<p>The following actions are currently registered:</p>\n"; <p>The following actions are currently registered:</p>\n";
$content .= "<p>" . implode(", ", array_keys(get_object_vars($actions))) . "</p>"; $content .= "<p>" . implode(", ", array_keys(get_object_vars($actions))) . "</p>";
$content .= "<h3>Environment</h3>\n"; $content .= "<h3>Environment</h3>\n";
$content .= "<p>$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.</p>"; $content .= "<ul>\n";
$content .= "<p>The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size.</p>"; $content .= "<li>$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.</li>\n";
$content .= "<li>The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size, and took " . $env->perfdata->pageindex_decode_time . "ms to decode.</li>";
if(module_exists("feature-search"))
{
search::measure_invindex_load_time($paths->searchindex);
$content .= "<li>The search index is currently " . human_filesize(filesize($paths->searchindex)) . " in size, and took " . $env->perfdata->searchindex_decode_time . "ms to decode.</li>";
}
$content .= "<li>The id index is currently " . human_filesize(filesize($paths->idindex)) . " in size, and took " . $env->perfdata->idindex_decode_time . "ms to decode.</li>";
} }
else else
{ {
@ -4783,7 +4804,7 @@ register_module([
"<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p> "<p>$settings->sitename's editor uses an extended version of <a href='http://parsedown.org/'>Parsedown</a> to render pages, which is a fantastic open source Github flavoured markdown parser. You can find a quick reference guide on Github flavoured markdown <a href='https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet'>here</a> by <a href='https://github.com/adam-p/'>adam-p</a>, or if you prefer a book <a href='https://www.gitbook.com/book/roachhd/master-markdown/details'>Mastering Markdown</a> by KB is a good read, and free too!</p>
<h3>Tips</h3> <h3>Tips</h3>
<ul> <ul>
<li>Put 2 spaces at the end of a line to add a soft line break. Leave a blank line to add a head line break (i.e. new paragraph).</li> <li>Put 2 spaces at the end of a line to add a soft line break. Leave a blank line to add a head line break (i.e. a new paragraph).</li>
<li>You can add an id to a header that you can link to. Put it in curly braces after the heading name like this: <code># Heading Name {#HeadingId}</code>. Then you can link to like like this: <code>[[Page name#HeadingId}]]</code>. You can also link to a heading id on the current page by omitting the page name: <code>[[#HeadingId]]</code>.</li> <li>You can add an id to a header that you can link to. Put it in curly braces after the heading name like this: <code># Heading Name {#HeadingId}</code>. Then you can link to like like this: <code>[[Page name#HeadingId}]]</code>. You can also link to a heading id on the current page by omitting the page name: <code>[[#HeadingId]]</code>.</li>
</ul> </ul>
<h3>Extra Syntax</h3> <h3>Extra Syntax</h3>

View file

@ -15,6 +15,7 @@ $env->user = "Anonymous";
$env->is_logged_in = false; $env->is_logged_in = false;
$env->is_admin = false; $env->is_admin = false;
$env->storage_prefix = $settings->data_storage_dir . DIRECTORY_SEPARATOR; $env->storage_prefix = $settings->data_storage_dir . DIRECTORY_SEPARATOR;
$env->perfdata = new stdClass();
/// Paths /// /// Paths ///
$paths = new stdClass(); $paths = new stdClass();
$paths->pageindex = "pageindex.json"; // The pageindex $paths->pageindex = "pageindex.json"; // The pageindex
@ -566,7 +567,8 @@ else
{ {
$pageindex_read_start = microtime(true); $pageindex_read_start = microtime(true);
$pageindex = json_decode(file_get_contents($paths->pageindex)); $pageindex = json_decode(file_get_contents($paths->pageindex));
header("x-pageindex-decode-time: " . round((microtime(true) - $pageindex_read_start)*1000, 3) . "ms"); $env->perfdata->pageindex_decode_time = round((microtime(true) - $pageindex_read_start)*1000, 3);
header("x-pageindex-decode-time: " . $env->perfdata->pageindex_decode_time . "ms");
} }
////////////////////////// //////////////////////////
@ -574,7 +576,9 @@ else
////////////////////////// //////////////////////////
if(!file_exists($paths->idindex)) if(!file_exists($paths->idindex))
file_put_contents($paths->idindex, "{}"); file_put_contents($paths->idindex, "{}");
$idindex_decode_start = microtime(true);
$idindex = json_decode(file_get_contents($paths->idindex)); $idindex = json_decode(file_get_contents($paths->idindex));
$env->perfdata->idindex_decode_time = round((microtime(true) - $idindex_decode_start)*1000, 3);
class ids class ids
{ {
/* /*

View file

@ -68,7 +68,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.", "description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id": "feature-search", "id": "feature-search",
"lastupdate": 1471632781, "lastupdate": 1471688611,
"optional": false "optional": false
}, },
{ {
@ -131,7 +131,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.",
"id": "page-help", "id": "page-help",
"lastupdate": 1466009992, "lastupdate": 1471688804,
"optional": false "optional": false
}, },
{ {
@ -203,7 +203,7 @@
"author": "Emanuil Rusev & Starbeamrainbowlabs", "author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown", "id": "parser-parsedown",
"lastupdate": 1471634318, "lastupdate": 1471634426,
"optional": false "optional": false
} }
] ]

View file

@ -318,6 +318,14 @@ class search
return $invindex; return $invindex;
} }
public static function measure_invindex_load_time($invindex_filename) {
global $env;
$searchindex_decode_start = microtime(true);
search::load_invindex($invindex_filename);
$env->perfdata->searchindex_decode_time = round((microtime(true) - $searchindex_decode_start)*1000, 3);
}
/* /*
* @summary Merge an index into an inverted index. * @summary Merge an index into an inverted index.
*/ */

View file

@ -26,7 +26,7 @@ register_module([
* ██ ██ ███████ ███████ ██ * ██ ██ ███████ ███████ ██
*/ */
add_action("help", function() { add_action("help", function() {
global $paths, $settings, $version, $help_sections, $actions; global $env, $paths, $settings, $version, $help_sections, $actions;
// Sort the help sections by key // Sort the help sections by key
ksort($help_sections, SORT_NATURAL); ksort($help_sections, SORT_NATURAL);
@ -53,8 +53,17 @@ register_module([
<p>The following actions are currently registered:</p>\n"; <p>The following actions are currently registered:</p>\n";
$content .= "<p>" . implode(", ", array_keys(get_object_vars($actions))) . "</p>"; $content .= "<p>" . implode(", ", array_keys(get_object_vars($actions))) . "</p>";
$content .= "<h3>Environment</h3>\n"; $content .= "<h3>Environment</h3>\n";
$content .= "<p>$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.</p>"; $content .= "<ul>\n";
$content .= "<p>The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size.</p>"; $content .= "<li>$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.</li>\n";
$content .= "<li>The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size, and took " . $env->perfdata->pageindex_decode_time . "ms to decode.</li>";
if(module_exists("feature-search"))
{
search::measure_invindex_load_time($paths->searchindex);
$content .= "<li>The search index is currently " . human_filesize(filesize($paths->searchindex)) . " in size, and took " . $env->perfdata->searchindex_decode_time . "ms to decode.</li>";
}
$content .= "<li>The id index is currently " . human_filesize(filesize($paths->idindex)) . " in size, and took " . $env->perfdata->idindex_decode_time . "ms to decode.</li>";
} }
else else
{ {