Change: (--query-preamble) Add (level) preamble
This commit is contained in:
parent
b1b04b3f19
commit
0fdfa65bef
2 changed files with 30 additions and 0 deletions
26
notes.org
26
notes.org
|
|
@ -410,6 +410,32 @@ Also, maybe instead of having a single =date= selector, I should have =scheduled
|
||||||
|
|
||||||
* Profiling
|
* Profiling
|
||||||
|
|
||||||
|
** Preambles
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp :results silent
|
||||||
|
(cl-defmacro org-ql-preamble-bench (&key query (file "tests/data.org") (times 10))
|
||||||
|
`(bench-multi-lets :times ,times :ensure-equal t
|
||||||
|
:lets (("preamble" ((org-ql-use-preamble t)))
|
||||||
|
("no preamble" ((org-ql-use-preamble nil))))
|
||||||
|
:forms ((,(prin1-to-string query) (org-ql-query ,file
|
||||||
|
',query
|
||||||
|
:action (lambda () (org-get-heading t t)))))))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** =level=
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(org-ql-preamble-bench :times 1
|
||||||
|
:file "~/org/inbox.org"
|
||||||
|
:query (level 1))
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
#+RESULTS:
|
||||||
|
| Form | x faster than next | Total runtime | # of GCs | Total GC runtime |
|
||||||
|
|------------------------+--------------------+---------------+----------+------------------|
|
||||||
|
| preamble: (level 1) | 1.34 | 0.562950 | 0 | 0 |
|
||||||
|
| no preamble: (level 1) | slowest | 0.754050 | 0 | 0 |
|
||||||
|
|
||||||
** Using =org-element-parse-buffer=
|
** Using =org-element-parse-buffer=
|
||||||
|
|
||||||
This basically works, as a very basic kind of agenda view, but we can already see that it's much slower (at least, for single-day views) because =org-element-parse-buffer= is slow compared to the agenda code.
|
This basically works, as a very basic kind of agenda view, but we can already see that it's much slower (at least, for single-day views) because =org-element-parse-buffer= is slow compared to the agenda code.
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,10 @@ replace the clause with a preamble."
|
||||||
(setq org-ql-preamble regexp)
|
(setq org-ql-preamble regexp)
|
||||||
;; Return nil
|
;; Return nil
|
||||||
nil))
|
nil))
|
||||||
|
(`(level ,num)
|
||||||
|
(let* ((regexp (rx-to-string `(seq bol (repeat ,num "*") " "))))
|
||||||
|
(setq org-ql-preamble regexp)
|
||||||
|
nil))
|
||||||
(`(and . ,rest)
|
(`(and . ,rest)
|
||||||
(let ((clauses (mapcar #'rec rest)))
|
(let ((clauses (mapcar #'rec rest)))
|
||||||
`(and ,@(-non-nil clauses))))
|
`(and ,@(-non-nil clauses))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue