From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Thierry Banel <tbanelwebmin@free.fr>
Cc: emacs-orgmode@gnu.org
Subject: Re: speeding up Babel Gnuplot
Date: Tue, 03 Jan 2017 22:55:16 +0100 [thread overview]
Message-ID: <87wpebbygr.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <586C1A53.90601@free.fr> (Thierry Banel's message of "Tue, 03 Jan 2017 22:40:35 +0100")
Hello,
Thierry Banel <tbanelwebmin@free.fr> writes:
> Here is a patch to avoid generating temporary files multiple times.
>
> There is no way to ensure a single call to
> (org-babel-gnuplot-process-vars) without modifying ob-core.el. I don't
> want to do that because I would have to change a lot of babel backends.
> Thus, I come back to my first light patch.
>
> A 'param' list is passed around. It reflects the #+BEGIN_SRC header. My
> patch changes it in-place from:
> (((:var data (3000) (2999) (2998) (2997) ...
> to:
> (((:var data . "/tmp/babel-16991kSr/gnuplot-16991YBq") ...
>
> The 'param' list behaves as a cache. There is nothing wrong with that.
> The worst thing that can happen is the caching no longer working in case
> 'param' would be copied some day. Results would stay correct.
Thank you.
What is the benefit of this patch? I mean,
`org-babel-gnuplot-process-vars' is already quite fast here. Do you have
some benchmark for that?
> (car pair) ;; variable name
> - (let* ((val (cdr pair)) ;; variable value
> - (lp (listp val)))
> - (if lp
> + (let ((val (cdr pair))) ;; variable value
> + (if (not (listp val))
> + val
> + (let ((temp-file (org-babel-temp-file "gnuplot-"))
> + (first (car val)))
> + (setcdr pair temp-file) ;; <------ caching here
It would be nice to expunge the comment a bit.
> (org-babel-gnuplot-table-to-data
> - (let* ((first (car val))
> - (tablep (or (listp first) (symbolp first))))
> - (if tablep val (mapcar 'list val)))
> - (org-babel-temp-file "gnuplot-") params)
> - val))))
> + (if (or (listp first) (symbolp first))
> + val
> + (mapcar 'list val))
> + temp-file params))))))
> (org-babel--get-vars params))))
>
> (defun org-babel-expand-body:gnuplot (body params)
Another option would be to generate a file according to the hash of
contents so `org-babel-gnuplot-process-vars' knows when to create a new
file.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2017-01-03 21:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-28 20:33 speeding up Babel Gnuplot Thierry Banel
2016-12-29 20:04 ` 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 [this message]
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wpebbygr.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=emacs-orgmode@gnu.org \
--cc=tbanelwebmin@free.fr \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.