class TimingSearcher extends app.Searcher

pull/1441/head
Simon Legner 1 year ago
parent 864e45e6fb
commit 164fa9a0c0

@ -34,43 +34,33 @@ app.start = function () {
// Searcher // Searcher
// //
const _super = app.Searcher; app.Searcher = class TimingSearcher extends app.Searcher {
const _proto = app.Searcher.prototype; setup() {
app.Searcher = function () {
_super.apply(this, arguments);
const _setup = this.setup.bind(this);
this.setup = function () {
console.groupCollapsed(`Search: ${this.query}`); console.groupCollapsed(`Search: ${this.query}`);
console.time("Total"); console.time("Total");
return _setup(); return super.setup();
}; }
const _match = this.match.bind(this); match() {
this.match = () => {
if (this.matcher) { if (this.matcher) {
console.timeEnd(this.matcher.name); console.timeEnd(this.matcher.name);
} }
return _match(); return super.match();
}; }
const _setupMatcher = this.setupMatcher.bind(this); setupMatcher() {
this.setupMatcher = function () {
console.time(this.matcher.name); console.time(this.matcher.name);
return _setupMatcher(); return super.setupMatcher();
}; }
const _end = this.end.bind(this); end() {
this.end = function () {
console.log(`Results: ${this.totalResults}`); console.log(`Results: ${this.totalResults}`);
console.timeEnd("Total"); console.timeEnd("Total");
console.groupEnd(); console.groupEnd();
return _end(); return super.end();
}; }
const _kill = this.kill.bind(this); kill() {
this.kill = function () {
if (this.timeout) { if (this.timeout) {
if (this.matcher) { if (this.matcher) {
console.timeEnd(this.matcher.name); console.timeEnd(this.matcher.name);
@ -79,14 +69,10 @@ app.Searcher = function () {
console.timeEnd("Total"); console.timeEnd("Total");
console.warn("Killed"); console.warn("Killed");
} }
return _kill(); return super.kill();
}; }
}; };
$.extend(app.Searcher, _super);
_proto.constructor = app.Searcher;
app.Searcher.prototype = _proto;
// //
// View tree // View tree
// //

Loading…
Cancel
Save