|
From: | Thierry Banel |
Subject: | [O] speeding up Babel Gnuplot |
Date: | Wed, 28 Dec 2016 21:33:00 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0 |
Babel Gnuplot is quite slow on large tables. Example: 45 seconds for a 1500 rows table. Why? Because orgtbl-to-generic is too slow (or too generic). Its behavior seems to be quadratic O(size^2). Should we bypass it? Should we try to optimize it? Here is a fix to speed up the rendering to a mere fraction of a second. #+BEGIN_SRC elisp (defun org-babel-gnuplot-table-to-data (table data-file params) "Export TABLE to DATA-FILE in a format readable by gnuplot." (let ((org-babel-gnuplot-timestamp-fmt (or (plist-get params :timefmt) "%Y-%m-%d-%H:%M:%S"))) (with-temp-file data-file (mapc (lambda (line) (mapc (lambda (cell) (insert (org-babel-gnuplot-quote-tsv-field cell)) (insert "\t")) line) (insert "\n")) table))) data-file) #+END_SRC And here is a test case. First generate a 1500 rows table: #+BEGIN_SRC elisp :results none (goto-char (point-max)) (insert "#+name: data\n") (let ((i 1500)) (while (> i 0) (goto-char (point-max)) (insert (format "| %4s |\n" i)) (setq i (1- i)))) #+END_SRC Then run Babel Gnuplot: #+BEGIN_SRC gnuplot :var data=data :file x.svg :session none :term svg plot data #+END_SRC
[Prev in Thread] | Current Thread | [Next in Thread] |