unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: "Germán Diago" <germandiago@gmail.com>
To: Arne Babenhauserheide <arne_bab@web.de>
Cc: guile-user@gnu.org
Subject: Re: Playing with guile (vs python). Generate file for GDP suitable for gnuplot.
Date: Wed, 1 Feb 2017 10:56:59 +0700	[thread overview]
Message-ID: <CAALp5N6Sn+F=8sUe_Uv4HankrprZ+Wo7S7_XbYEf=dv6xmcA7w@mail.gmail.com> (raw)
In-Reply-To: <87tw8fjc34.fsf@web.de>

>
> If I understand your script correctly, you want to grab all lines with
> GDP, sort the values by year and country and output them. Is that right?
>
> As a first warning: the csv module in Python mainly calls into a C-based
> implementation (_csv, see csv.__file__), so it will be hard to beat this
> in pure Scheme.
>
> Good to know.


> But now, let’s begin with the optimization. These are my times:
>
> $ time guile-2.0 extract_gdp.scm
> real    0m0.509s
> $ time python3 extract_gdp.py
> real    0m0.089s
>
> The first step is using Guile 2.1.6 instead of 2.0. That reduces the
> runtime by 40% to 0.3s. Source: ftp://alpha.gnu.org/gnu/guile/
> guile-2.1.6.tar.xz
>
>
Thanks.


> $ time guile extract_gdp.scm
> real    0m0.296s
> $ time python3 extract_gdp.py
> real    0m0.089s
>
> So there’s a factor of 3.3 between Python and Guile on my machine.
>
>
> Aside from using a more recent Guile, I do not see obvious
> optimizations, however (more exactly: all my tries to speedup the code
> only made it slower).
>

I was struggling with using read-line! instead of read-line but
experimenting in the command line
I cannot figure out how it works actually. read-line! will reuse a buffered
string. There was lots of time spent there, I am not sure if because of
allocations or just because of I/O. If someone could tell me how to do it...

Thanks for your time Arne!


  reply	other threads:[~2017-02-01  3:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31  5:19 Playing with guile (vs python). Generate file for GDP suitable for gnuplot Germán Diago
2017-01-31  7:40 ` Alex Vong
2017-01-31  9:41 ` Arne Babenhauserheide
2017-02-01  3:56   ` Germán Diago [this message]
2017-02-01 22:24     ` Arne Babenhauserheide
2017-02-02  8:32       ` Germán Diago
2017-02-11 14:12 ` Ludovic Courtès
2017-03-06 13:50   ` Thien-Thi Nguyen
2017-03-06 21:02     ` Andy Wingo

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.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAALp5N6Sn+F=8sUe_Uv4HankrprZ+Wo7S7_XbYEf=dv6xmcA7w@mail.gmail.com' \
    --to=germandiago@gmail.com \
    --cc=arne_bab@web.de \
    --cc=guile-user@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.
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).