From: Thierry Banel <tbanelwebmin@free.fr>
To: emacs-orgmode@gnu.org
Subject: speeding up Babel Gnuplot
Date: Wed, 28 Dec 2016 21:33:00 +0100 [thread overview]
Message-ID: <5864217C.7060001@free.fr> (raw)
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
next reply other threads:[~2016-12-28 20:33 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 20:33 Thierry Banel [this message]
2016-12-29 20:04 ` speeding up Babel Gnuplot Nicolas Goaziou
2016-12-29 20:34 ` Thierry Banel
2017-01-01 20:17 ` Thierry Banel
2017-01-01 23:34 ` Nicolas Goaziou
2017-01-02 20:11 ` Thierry Banel
2017-01-03 21:40 ` Thierry Banel
2017-01-03 21:55 ` Nicolas Goaziou
2017-01-03 23:06 ` Thierry Banel
2017-01-04 22:36 ` Nicolas Goaziou
2017-01-05 20:47 ` Thierry Banel
2017-01-06 9:41 ` Nicolas Goaziou
2017-01-06 18:24 ` Thierry Banel
2017-01-04 17:32 ` Achim Gratz
2017-01-04 20:29 ` Thierry Banel
2017-01-04 23:15 ` Charles C. Berry
2017-01-05 20:23 ` Thierry Banel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5864217C.7060001@free.fr \
--to=tbanelwebmin@free.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).