1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Add user interface for enabling performance instrumentation

This commit is contained in:
Jermolene 2015-10-14 10:59:46 +01:00
parent 093f507319
commit 33563d01ba
5 changed files with 17 additions and 4 deletions

View File

@ -90,6 +90,9 @@ Settings/NavigationHistory/Caption: Navigation History
Settings/NavigationHistory/Hint: Update browser history when navigating to a tiddler:
Settings/NavigationHistory/No/Description: Do not update history
Settings/NavigationHistory/Yes/Description: Update history
Settings/PerformanceInstrumentation/Caption: Performance Instrumentation
Settings/PerformanceInstrumentation/Hint: Displays performance statistics in the browser developer console. Requires reload to take effect
Settings/PerformanceInstrumentation/Description: Enable performance instrumentation
Settings/ToolbarButtonStyle/Caption: Toolbar Button Style
Settings/ToolbarButtonStyle/Hint: Choose the style for toolbar buttons:
Settings/ToolbarButtonStyle/Styles/Borderless: Borderless

View File

@ -18,7 +18,7 @@ exports.after = ["load-modules"];
exports.synchronous = true;
// Set to `true` to enable performance instrumentation
var PERFORMANCE_INSTRUMENTATION = false;
var PERFORMANCE_INSTRUMENTATION_CONFIG_TITLE = "$:/config/Performance/Instrumentation";
var widget = require("$:/core/modules/widgets/widget.js");
@ -29,7 +29,7 @@ exports.startup = function() {
}
$tw.version = $tw.utils.extractVersionInfo();
// Set up the performance framework
$tw.perf = new $tw.Performance(PERFORMANCE_INSTRUMENTATION);
$tw.perf = new $tw.Performance($tw.wiki.getTiddlerText(PERFORMANCE_INSTRUMENTATION_CONFIG_TITLE,"no") === "yes");
// Kick off the language manager and switcher
$tw.language = new $tw.Language();
$tw.languageSwitcher = new $tw.PluginSwitcher({

View File

@ -28,9 +28,9 @@ Performance.prototype.report = function(name,fn) {
self.measures = {};
var startTime = $tw.utils.timer(),
result = fn.apply(this,arguments);
self.logger.log(name + ": " + $tw.utils.timer(startTime) + "ms");
self.logger.log(name + ": " + $tw.utils.timer(startTime).toFixed(2) + "ms");
for(var m in self.measures) {
self.logger.log("+" + m + ": " + self.measures[m] + "ms");
self.logger.log("+" + m + ": " + self.measures[m].toFixed(2) + "ms");
}
return result;
};

View File

@ -0,0 +1,8 @@
title: $:/core/ui/ControlPanel/Settings/PerformanceInstrumentation
tags: $:/tags/ControlPanel/Settings
caption: {{$:/language/ControlPanel/Settings/PerformanceInstrumentation/Caption}}
\define lingo-base() $:/language/ControlPanel/Settings/PerformanceInstrumentation/
<<lingo Hint>>
<$checkbox tiddler="$:/config/Performance/Instrumentation" field="text" checked="yes" unchecked="no" default="no"> <$link to="$:/config/Performance/Instrumentation"><<lingo Description>></$link> </$checkbox>

View File

@ -0,0 +1,2 @@
title: $:/config/Performance/Instrumentation
text: yes