[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] speeding up Babel Gnuplot
From: |
Nicolas Goaziou |
Subject: |
Re: [O] speeding up Babel Gnuplot |
Date: |
Tue, 03 Jan 2017 22:55:16 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
Hello,
Thierry Banel <address@hidden> 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
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/01
- Re: [O] speeding up Babel Gnuplot, Nicolas Goaziou, 2017/01/01
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/02
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/03
- Re: [O] speeding up Babel Gnuplot,
Nicolas Goaziou <=
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/03
- Re: [O] speeding up Babel Gnuplot, Nicolas Goaziou, 2017/01/04
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/05
- Re: [O] speeding up Babel Gnuplot, Nicolas Goaziou, 2017/01/06
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/06
- Re: [O] speeding up Babel Gnuplot, Achim Gratz, 2017/01/04
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/04
- Re: [O] speeding up Babel Gnuplot, Charles C. Berry, 2017/01/04
- Re: [O] speeding up Babel Gnuplot, Thierry Banel, 2017/01/05