From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: speeding up Babel Gnuplot Date: Thu, 29 Dec 2016 21:04:50 +0100 Message-ID: <8760m2mrh9.fsf@nicolasgoaziou.fr> References: <5864217C.7060001@free.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cMgwa-0000KX-1v for emacs-orgmode@gnu.org; Thu, 29 Dec 2016 15:04:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cMgwZ-0002nH-6E for emacs-orgmode@gnu.org; Thu, 29 Dec 2016 15:04:56 -0500 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:45425) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cMgwZ-0002mm-0l for emacs-orgmode@gnu.org; Thu, 29 Dec 2016 15:04:55 -0500 In-Reply-To: <5864217C.7060001@free.fr> (Thierry Banel's message of "Wed, 28 Dec 2016 21:33:00 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Thierry Banel Cc: emacs-orgmode@gnu.org Hello, Thierry Banel writes: > 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? I don't think so. > Should we try to optimize it? I did some optimizations in master branch. I go below 1 sec for the 1500 rows table. > 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 The comparison is not fair, because the function doesn't handle all the cases `orgtbl-to-generic' handles. Regards, -- Nicolas Goaziou