(defmacro time-stringy (class what thing) `(progn (let ((reps 5000) t0 t1 t2 t3) (garbage-collect) (setq t0 (float-time)) (--dotimes reps (org-element-interpret-data ,thing)) (setq t1 (float-time)) (garbage-collect) (setq t2 (float-time)) (--dotimes reps (org-ml-to-string ,thing)) (setq t3 (float-time)) (format "%s, %s, %f, %f" ,class ,what (- t3 t2) (- t1 t0))))) (defun run-tests () (let* ((text "abc") ;; value objects (code (org-ml-build-code "abc")) (verbatim (org-ml-build-verbatim "abc")) (target (org-ml-build-target "abc")) (ibcall (org-ml-build-inline-babel-call "abc")) (isblock (org-ml-build-inline-src-block "abc" :value "xyz")) (break (org-ml-build-line-break)) (macro (org-ml-build-macro "abc")) (stat (org-ml-build-statistics-cookie '(1 2))) ;; recursive objects (bold (org-ml-build-bold "abc")) (radio-target (org-ml-build-radio-target "abc")) (strike (org-ml-build-strike-through "abc")) (italic (org-ml-build-italic "abc")) (underline (org-ml-build-underline "abc")) (subscript (org-ml-build-subscript :use-brackets-p t "abc")) (superscript (org-ml-build-superscript :use-brackets-p t "abc")) (cell (org-ml-build-table-cell "abc")) (link (org-ml-build-link "https://downloadmoreram.com" "abc")) (fnref (org-ml-build-footnote-reference "abc")) ;; other objects (latex-frag (org-ml-build-latex-fragment "abc")) (keyword (org-ml-build-keyword "thing" "abc")) (timestamp (org-ml-build-timestamp! '(2024 1 1 0 0))) (timestamp-long (org-ml-build-timestamp! '(2024 1 1 0 0) :end '(2024 1 1 1 0) :collapsed nil :repeater '(cumulate 10 day) :deadline '(14 day) :warning '(all 2 day) )) (entity (org-ml-build-entity "Agrave")) (export-snip (org-ml-build-export-snippet "abc" "xyz")) ;; leaf elements (comment (org-ml-build-comment "abc")) (comment-block (org-ml-build-comment-block :value "abc")) (example-block (org-ml-build-example-block :value "abc")) (horz (org-ml-build-horizontal-rule)) (export-block (org-ml-build-export-block "abc" "xyz")) (fixed-width (org-ml-build-fixed-width "abc")) (clock (org-ml-build-clock! '(2024 1 1 0 0))) (clock-long (org-ml-build-clock! '(2024 1 1 0 0) :end '(2024 1 1 1 1))) (bcall (org-ml-build-babel-call "abc")) (diary-sexp (org-ml-build-diary-sexp :value '(poop))) (latex-env (org-ml-build-latex-environment (list "abc" "xyz"))) (node-prop (org-ml-build-node-property "abc" "xyz")) (plan (org-ml-build-planning! :closed '(2024 1 1))) (plan-long (org-ml-build-planning! :closed '(2024 1 1) :scheduled '(2024 1 1) :deadline '(2024 1 1))) (src-block (org-ml-build-src-block :value "abc")) ;; elements with objects (para0 (org-ml-build-paragraph)) (row0 (org-ml-build-table-row)) (verse0 (org-ml-build-verse-block)) (para3 (org-ml-build-paragraph text text text)) (row3 (org-ml-build-table-row cell cell cell)) (verse3 (org-ml-build-verse-block text text text)) (para6 (org-ml-build-paragraph text text text text text text)) (row6 (org-ml-build-table-row cell cell cell cell cell cell)) (verse6 (org-ml-build-verse-block text text text text text text)) ;; greater elements (item (org-ml-build-item! :bullet '- :checkbox 'on :paragraph "abc")) (hl0 (org-ml-build-headline! :title-text "abc" :todo-keyword "TODO" :tags '("poopy" "butthole"))) (hl3 (org-ml-build-headline! :title-text "abc" :todo-keyword "TODO" :tags '("poopy" "butthole") :section-children (-repeat 3 para3))) (hl6 (org-ml-build-headline! :title-text "abc" :todo-keyword "TODO" :tags '("poopy" "butthole") :section-children (-repeat 3 para3))) (pd0 (org-ml-build-property-drawer)) (pd3 (apply #'org-ml-build-property-drawer! (-repeat 3 '("abc" "xyz")))) (pd6 (apply #'org-ml-build-property-drawer! (-repeat 6 '("abc" "xyz")))) (pl3 (apply #'org-ml-build-plain-list (-repeat 3 item))) (pl6 (apply #'org-ml-build-plain-list (-repeat 6 item))) (drawer0 (org-ml-build-drawer "abc")) (drawer3 (org-ml-build-drawer "abc" pl3)) (drawer6 (org-ml-build-drawer "abc" pl6)) (table3 (apply #'org-ml-build-table (-repeat 3 row3))) (table6 (apply #'org-ml-build-table (-repeat 6 row6))) ) (->> (list (time-stringy "plain" "text" text) (time-stringy "object" "code" code) (time-stringy "object" "verbatim" verbatim) (time-stringy "object" "target" target) (time-stringy "object" "inline-babel-call" ibcall) (time-stringy "object" "inline-src-block" isblock) (time-stringy "object" "entity" entity) (time-stringy "object" "keyword" keyword) (time-stringy "object" "timestamp" timestamp) (time-stringy "object" "timestamp-long" timestamp-long) (time-stringy "object" "latex-frag" latex-frag) (time-stringy "object" "export-snippet" export-snip) (time-stringy "object" "line-break" break) (time-stringy "object" "macro" macro) (time-stringy "object" "statcookie" stat) (time-stringy "recursive object" "bold" bold) (time-stringy "recursive object" "strikethru" strike) (time-stringy "recursive object" "italic" italic) (time-stringy "recursive object" "underline" underline) (time-stringy "recursive object" "superscript" superscript) (time-stringy "recursive object" "subscript" subscript) (time-stringy "recursive object" "cell" cell) (time-stringy "recursive object" "link" link) (time-stringy "recursive object" "footnote-ref" fnref) (time-stringy "recursive object" "radio-target" radio-target) (time-stringy "element" "babel call" bcall) (time-stringy "element" "comment" comment) (time-stringy "element" "comment-block" comment-block) (time-stringy "element" "clock" clock) (time-stringy "element" "clock-long" clock-long) (time-stringy "element" "diary-sexp" diary-sexp) (time-stringy "element" "export-block" export-block) (time-stringy "element" "example-block" example-block) (time-stringy "element" "fixed-width" fixed-width) (time-stringy "element" "horizontal rule" horz) (time-stringy "element" "latex env" latex-env) (time-stringy "element" "prop" node-prop) (time-stringy "element" "planning" plan) (time-stringy "element" "planning-long" plan-long) (time-stringy "element" "src-block" src-block) (time-stringy "element with objects" "paragraph0" para0) (time-stringy "element with objects" "table-row0" row0) (time-stringy "element with objects" "verse-block0" verse0) (time-stringy "element with objects" "paragraph3" para3) (time-stringy "element with objects" "table-row3" row3) (time-stringy "element with objects" "verse-block3" verse3) (time-stringy "element with objects" "paragraph6" para6) (time-stringy "element with objects" "table-row6" row6) (time-stringy "element with objects" "verse-block6" verse6) (time-stringy "greater element" "headline0" hl0) (time-stringy "greater element" "headline3" hl3) ;; (time-stringy "greater element" "headline6" hl6) (time-stringy "greater element" "drawer0" drawer0) (time-stringy "greater element" "drawer3" drawer3) ;; (time-stringy "greater element" "drawer6" drawer6) (time-stringy "greater element" "item" item) (time-stringy "greater element" "property-drawer0" pd0) (time-stringy "greater element" "property-drawer3" pd3) ;; (time-stringy "greater element" "property-drawer6" pd6) (time-stringy "greater element" "plain-list3" pl3) ;; (time-stringy "greater element" "plain-list6" pl6) (time-stringy "greater element" "table3" table3) ;; (time-stringy "greater element" "table6" table6) ) (s-join "\n")))) ;; (run-tests) (--> (-repeat 5 (run-tests)) (s-join "\n" it) (f-write-text it 'utf-8 "/tmp/runs_interpret.out"))