Asking for advice on programming style and also performance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Asking for advice on programming style and also performance

Harald Bögeholz
Dear Haskell Cafe,


I am working on a solver for Slitherlink puzzles in Haskell. Today I am
completely puzzled that a small change I made had a huge performance
impact. I thought the change to be merely cosmetic to make a function a
little more elegant and the code more readable. But this change slowed
down my program by a factor of 100!

I would greatly appreciate advice from experienced Haskellers why this
has happened. The program is hosted on github; this is the direct link
to the change with unexpected outcome:

https://github.com/ctbo/slitherlink/commit/b6f58699258ef68ddee21a1346bd184465aaaba2

The program itself isn't commented at all, but I have written a sketch
of how it works in the wiki:

https://github.com/ctbo/slitherlink/wiki/How-it-works

While I am at it:

I would also appreciate any advice you might have on the programming
style in general. I am relatively new to Haskell and this is my first
nontrivial program. So any suggestions for improvements are welcome!


Thanks for your time,

--
Harald Bögeholz    <[hidden email]> (PGP key available from servers)
Redaktion c't      Tel.: +49 511 5352-300  Fax: +49 511 5352-417
                   http://www.ct.de/

                   int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
                   main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
                   while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}
                                                          (Arndt/Haenel)

                   Affe Apfel Vergaser

/* Heise Zeitschriften Verlag GmbH & Co. KG * Karl-Wiechert-Allee 10 *
   30625 Hannover * Registergericht: Amtsgericht Hannover HRA 26709 *
   Persönlich haftende Gesellschafterin: Heise Zeitschriften Verlag *
   Geschäftsführung GmbH * Registergericht: Amtsgericht Hannover, HRB
   60405 * Geschäftsführer: Ansgar Heise, Dr. Alfons Schräder */

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Asking for advice on programming style and also performance

Joachim Breitner-2
Hi,

Am Montag, den 03.09.2012, 18:31 +0200 schrieb Harald Bögeholz:
> I would greatly appreciate advice from experienced Haskellers why this
> has happened. The program is hosted on github; this is the direct link
> to the change with unexpected outcome:
>
> https://github.com/ctbo/slitherlink/commit/b6f58699258ef68ddee21a1346bd184465aaaba2

I’m not sure if you are notified via github, but there are comments
there below the commit.

Greetings,
Joachim

--
Joachim "nomeata" Breitner
  [hidden email]  |  [hidden email]  |  GPG: 0x4743206C
  xmpp: [hidden email] | http://www.joachim-breitner.de/


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe

signature.asc (205 bytes) Download Attachment