Skip to content

Instantly share code, notes, and snippets.

@dmgerman
Created May 26, 2024 18:45
Show Gist options
  • Save dmgerman/4d46d4883c20bf9e4fa6964416e93cbb to your computer and use it in GitHub Desktop.
Save dmgerman/4d46d4883c20bf9e4fa6964416e93cbb to your computer and use it in GitHub Desktop.
Test Node Constructor #org
(defun test-node-creation-original (rows)
    (cl-loop for row in rows
             append (pcase-let* ((`(,id ,file ,file-title ,level ,todo
                                        ,pos ,priority ,scheduled ,deadline
                                        ,title ,properties ,olp  ;;12
                                        ,atime ,mtime ,tags ,aliases ,refs)
                                  row)
                                 (all-titles (cons title aliases)))
                      (mapcar (lambda (temp-title)
                                (org-roam-node-create :id id
                                                      :file file
                                                      :file-title file-title
                                                      :file-atime atime
                                                      :file-mtime mtime
                                                      :level level
                                                      :point pos
                                                      :todo todo
                                                      :priority priority
                                                      :scheduled scheduled
                                                      :deadline deadline
                                                      :title temp-title
                                                      :aliases aliases
                                                      :properties properties
                                                      :olp olp
                                                      :tags tags
                                                      :refs refs))
                              all-titles)))))
test-node-creation-original
(defun test-node-creation-new (rows)
   (mapcan
     (lambda (row)
       (let (
              (all-titles (cons (car row) (nth 1 row)))
              )
         (mapcar (lambda (temp-title)
                   (apply 'org-roam-node-create-from-db (cons temp-title (cdr row))))
                 all-titles)
       ))
     rows)
     )
test-node-creation-new
(setq test-list (make-list 100000
                           '("a" ("bb") "c" "d" "e" ;; 5
                             "f" "g" "h" "i" "j"     ; 10
                             "k"  "l" "m" "n" "o"   ;; 15
                             ("xa") ("aa")))) ;; 18

1
1
(defun dmg-test-function ()
  (test-node-creation-original test-list))

(cl-loop
 for i from 1 to 10
 collect (benchmark-run 1 (dmg-test-function)))

10.53726300000000130.7531709999999947
11.29661741.158483000000004
11.04304200000000241.0624009999999942
10.7836741.0448480000000018
10.58498630.7671279999999996
11.32153141.2324100000000016
11.16518841.0686970000000002
11.36464841.1126469999999955
10.92709430.8215220000000016
11.18180141.1664640000000048
(defun dmg-test-function2 ()
  (test-node-creation-new test-list))

(cl-loop
 for i from 1 to 10
 collect (benchmark-run 1 (dmg-test-function2)))

1.41863110.27120800000000145
1.150600.0
1.37313910.23833300000001145
1.36851410.2306819999999874
1.37530510.22759200000000135
1.35338810.23199800000000437
1.36987310.23419200000000728
1.37401910.23432599999999582
1.37038110.2383299999999906
1.39043910.23972100000000296
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment