History

class TimingSearcher extends app.Searcher

Simon Legner committed 2 years ago

Commit 164fa9a1 parent 864e45e1 file · +16 −30Browse files

Unified · Split

assets/javascripts/debug.js+16−30
@@ -34,43 +34,33 @@ app.start = function () { · 33 unmodified lines
34// Searcher34// Searcher
35//35//
36 36
37const _super = app.Searcher;37app.Searcher = class TimingSearcher extends app.Searcher {
38const _proto = app.Searcher.prototype;38 setup() {
39
40app.Searcher = function () {
41 _super.apply(this, arguments);
42
43 const _setup = this.setup.bind(this);
44 this.setup = function () {
45 console.groupCollapsed(`Search: ${this.query}`);39 console.groupCollapsed(`Search: ${this.query}`);
46 console.time("Total");40 console.time("Total");
47 return _setup();41 return super.setup();
48 };42 }
49 43
50 const _match = this.match.bind(this);44 match() {
51 this.match = () => {
52 if (this.matcher) {45 if (this.matcher) {
53 console.timeEnd(this.matcher.name);46 console.timeEnd(this.matcher.name);
54 }47 }
55 return _match();48 return super.match();
56 };49 }
57 50
58 const _setupMatcher = this.setupMatcher.bind(this);51 setupMatcher() {
59 this.setupMatcher = function () {
60 console.time(this.matcher.name);52 console.time(this.matcher.name);
61 return _setupMatcher();53 return super.setupMatcher();
62 };54 }
63 55
64 const _end = this.end.bind(this);56 end() {
65 this.end = function () {
66 console.log(`Results: ${this.totalResults}`);57 console.log(`Results: ${this.totalResults}`);
67 console.timeEnd("Total");58 console.timeEnd("Total");
68 console.groupEnd();59 console.groupEnd();
69 return _end();60 return super.end();
70 };61 }
71 62
72 const _kill = this.kill.bind(this);63 kill() {
73 this.kill = function () {
74 if (this.timeout) {64 if (this.timeout) {
75 if (this.matcher) {65 if (this.matcher) {
76 console.timeEnd(this.matcher.name);66 console.timeEnd(this.matcher.name);
@@ -79,14 +69,10 @@ app.Searcher = function () { · 2 unmodified lines
79 console.timeEnd("Total");69 console.timeEnd("Total");
80 console.warn("Killed");70 console.warn("Killed");
81 }71 }
82 return _kill();72 return super.kill();
83 };73 }
84};74};
85 75
86$.extend(app.Searcher, _super);
87_proto.constructor = app.Searcher;
88app.Searcher.prototype = _proto;
89
90//76//
91// View tree77// View tree
92//78//