<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Speed Problems: C vs. Gambit Scheme</title>
	<atom:link href="http://etherplex.org/archives/150/feed" rel="self" type="application/rss+xml" />
	<link>http://etherplex.org/archives/150</link>
	<description>Rick Dillon&#039;s home on the net...</description>
	<lastBuildDate>Sun, 06 May 2012 00:20:09 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: effiltUnina</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-2683</link>
		<dc:creator>effiltUnina</dc:creator>
		<pubDate>Fri, 28 Oct 2011 13:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-2683</guid>
		<description>Hi!  
send you post:  to my @aqiuuyhw twitter</description>
		<content:encoded><![CDATA[<p>Hi!<br />
send you post:  to my @aqiuuyhw twitter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-195</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Tue, 04 May 2010 23:44:48 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-195</guid>
		<description>Or you could take your original code, convert all the integers to floats and compile it with a different scheme compiler.

Using  bigloo 3.3a I get the following timings...
&lt;code&gt;
bash-3.00$ bigloo -O3 -suffix scheme -native pi.scheme  -o pi3
bash-3.00$ time ./pi3
3.1415949166667

real    0m1.913s
user    0m1.910s
sys     0m0.000s
bash-3.00$ time pi-c
Estimate of pi is: 3.14159492

real    0m1.570s
user    0m1.560s
sys     0m0.010s
&lt;/code&gt;

Using the following code...

&lt;code&gt;
(module pi
	(main main2))

(define (main2 args)
  (display (string-append (number-&gt;string (exact-&gt;inexact (main &#039;()))) &quot;\n&quot;)))



(define (main args)
  (let* ((partitions 12000.)
         (increment (/ 1. partitions))
         (count 0.))

    (do ((y 0. (+ 1. y)))
        ((= partitions y) (* 4. (/ count (* partitions partitions))))
      (let ((b (* increment (+ y .5))))
        (do ((x 0. (+ 1. x)))

            ((= partitions x))
          (let ((a (* increment (+ x .5))))
            (if (&lt; (+ (* a a) (* b b)) 1.)
                (set! count (+ 1. count)))))))))
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Or you could take your original code, convert all the integers to floats and compile it with a different scheme compiler.</p>
<p>Using  bigloo 3.3a I get the following timings&#8230;<br />
<code><br />
bash-3.00$ bigloo -O3 -suffix scheme -native pi.scheme  -o pi3<br />
bash-3.00$ time ./pi3<br />
3.1415949166667</p>
<p>real    0m1.913s<br />
user    0m1.910s<br />
sys     0m0.000s<br />
bash-3.00$ time pi-c<br />
Estimate of pi is: 3.14159492</p>
<p>real    0m1.570s<br />
user    0m1.560s<br />
sys     0m0.010s<br />
</code></p>
<p>Using the following code&#8230;</p>
<p><code><br />
(module pi<br />
	(main main2))</p>
<p>(define (main2 args)<br />
  (display (string-append (number-&gt;string (exact-&gt;inexact (main '()))) "\n")))</p>
<p>(define (main args)<br />
  (let* ((partitions 12000.)<br />
         (increment (/ 1. partitions))<br />
         (count 0.))</p>
<p>    (do ((y 0. (+ 1. y)))<br />
        ((= partitions y) (* 4. (/ count (* partitions partitions))))<br />
      (let ((b (* increment (+ y .5))))<br />
        (do ((x 0. (+ 1. x)))</p>
<p>            ((= partitions x))<br />
          (let ((a (* increment (+ x .5))))<br />
            (if (&lt; (+ (* a a) (* b b)) 1.)<br />
                (set! count (+ 1. count)))))))))<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axio</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-185</link>
		<dc:creator>Axio</dc:creator>
		<pubDate>Mon, 22 Mar 2010 08:40:17 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-185</guid>
		<description>Yeah. It&#039;s the same code with more explicit typing and better precalculation.</description>
		<content:encoded><![CDATA[<p>Yeah. It&#8217;s the same code with more explicit typing and better precalculation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Axio</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-184</link>
		<dc:creator>Axio</dc:creator>
		<pubDate>Mon, 22 Mar 2010 08:25:42 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-184</guid>
		<description>/tmp % time gsi-gambit loop2
3.1415949166666666
gsi-gambit loop2  101.80s user 1.65s system 97% cpu 1:45.65 total
[adrien]/tmp % time ./loop-c
Estimate of pi is: 3.14159492
./loop-c  1.11s user 0.00s system 99% cpu 1.124 total


(declare (block) (standard-bindings) (extended-bindings) (not safe))

(define (main args)
  (let ((num-partitions 12000.)
        (num-partitions-ex 12000))
    (let ((interval (fl/ 1. num-partitions)))
      (let loop ((i 0) (circle-count 0))
        (if (&lt; i num-partitions-ex)
          (let ((new-circle-count
                  (let loop2 ((j 0) (circle-count circle-count))
                    (if (&lt; j num-partitions-ex)
                      (let ((a2 (flexpt (fl* (+ i .5) interval) 2.))
                            (b2 (flexpt (fl* (+ j .5) interval) 2.)))
                        (loop2 (+ j 1)
                               (if (string (exact-&gt;inexact (main &#039;()))) &quot;\n&quot;))


I guess that I&#039;m still far from Gambiteer&#039;s performance, but it&#039;s still better than your original code ^^</description>
		<content:encoded><![CDATA[<p>/tmp % time gsi-gambit loop2<br />
3.1415949166666666<br />
gsi-gambit loop2  101.80s user 1.65s system 97% cpu 1:45.65 total<br />
[adrien]/tmp % time ./loop-c<br />
Estimate of pi is: 3.14159492<br />
./loop-c  1.11s user 0.00s system 99% cpu 1.124 total</p>
<p>(declare (block) (standard-bindings) (extended-bindings) (not safe))</p>
<p>(define (main args)<br />
  (let ((num-partitions 12000.)<br />
        (num-partitions-ex 12000))<br />
    (let ((interval (fl/ 1. num-partitions)))<br />
      (let loop ((i 0) (circle-count 0))<br />
        (if (&lt; i num-partitions-ex)<br />
          (let ((new-circle-count<br />
                  (let loop2 ((j 0) (circle-count circle-count))<br />
                    (if (&lt; j num-partitions-ex)<br />
                      (let ((a2 (flexpt (fl* (+ i .5) interval) 2.))<br />
                            (b2 (flexpt (fl* (+ j .5) interval) 2.)))<br />
                        (loop2 (+ j 1)<br />
                               (if (string (exact-&gt;inexact (main &#8216;()))) &#8220;\n&#8221;))</p>
<p>I guess that I&#8217;m still far from Gambiteer&#8217;s performance, but it&#8217;s still better than your original code ^^</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gambiteer</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-182</link>
		<dc:creator>Gambiteer</dc:creator>
		<pubDate>Wed, 17 Mar 2010 02:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-182</guid>
		<description>See

http://paste.lisp.org/display/96491#4</description>
		<content:encoded><![CDATA[<p>See</p>
<p><a href="http://paste.lisp.org/display/96491#4" rel="nofollow">http://paste.lisp.org/display/96491#4</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gambiteer</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-181</link>
		<dc:creator>Gambiteer</dc:creator>
		<pubDate>Wed, 17 Mar 2010 02:17:56 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-181</guid>
		<description>&lt;code&gt;
(declare (standard-bindings)
	 (extended-bindings)
	 (block)
	 (not safe))

(define (main args)
  (let* ((partitions 12000)
	 (increment (fl/ (fixnum-&gt;flonum partitions))))
    (let y-loop ((y 0)
		 (count 0))
      (if (fx= partitions y)
	  (* 4 (/ count (* partitions partitions)))
	  (let ((b (fl* increment (fl+ (fixnum-&gt;flonum y) 0.5))))
	    (let x-loop ((x 0)
			 (count count))
	      (if (fx= partitions x)
		  (y-loop (fx+ y 1)
			  count)
		  (let ((a (fl* increment (fl+ (fixnum-&gt;flonum x) 0.5))))
		    (if (flstring (exact-&gt;inexact (main &#039;()))) &quot;\n&quot;))
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><code><br />
(declare (standard-bindings)<br />
	 (extended-bindings)<br />
	 (block)<br />
	 (not safe))</p>
<p>(define (main args)<br />
  (let* ((partitions 12000)<br />
	 (increment (fl/ (fixnum-&gt;flonum partitions))))<br />
    (let y-loop ((y 0)<br />
		 (count 0))<br />
      (if (fx= partitions y)<br />
	  (* 4 (/ count (* partitions partitions)))<br />
	  (let ((b (fl* increment (fl+ (fixnum-&gt;flonum y) 0.5))))<br />
	    (let x-loop ((x 0)<br />
			 (count count))<br />
	      (if (fx= partitions x)<br />
		  (y-loop (fx+ y 1)<br />
			  count)<br />
		  (let ((a (fl* increment (fl+ (fixnum-&gt;flonum x) 0.5))))<br />
		    (if (flstring (exact-&gt;inexact (main '()))) "\n"))<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gambiteer</title>
		<link>http://etherplex.org/archives/150/comment-page-1#comment-180</link>
		<dc:creator>Gambiteer</dc:creator>
		<pubDate>Wed, 17 Mar 2010 02:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://etherplex.org/archives/150#comment-180</guid>
		<description>(declare (standard-bindings)
	 (extended-bindings)
	 (block)
	 (not safe))

(define (main args)
  (let* ((partitions 12000)
	 (increment (fl/ (fixnum-&gt;flonum partitions))))
    (let y-loop ((y 0)
		 (count 0))
      (if (fx= partitions y)
	  (* 4 (/ count (* partitions partitions)))
	  (let ((b (fl* increment (fl+ (fixnum-&gt;flonum y) 0.5))))
	    (let x-loop ((x 0)
			 (count count))
	      (if (fx= partitions x)
		  (y-loop (fx+ y 1)
			  count)
		  (let ((a (fl* increment (fl+ (fixnum-&gt;flonum x) 0.5))))
		    (if (flstring (exact-&gt;inexact (main &#039;()))) &quot;\n&quot;))

:~&gt; gcc -O3 -Wall -o pic pic.c
:~&gt; time ./pic
Estimate of pi is: 3.14159492
1.230u 0.000s 0:01.23 100.0%	0+0k 0+0io 0pf+0w
:~&gt; gsc pi
:~&gt; time gsi pi
3.1415949166666666
1.250u 0.000s 0:01.25 100.0%	0+0k 0+0io 0pf+0w</description>
		<content:encoded><![CDATA[<p>(declare (standard-bindings)<br />
	 (extended-bindings)<br />
	 (block)<br />
	 (not safe))</p>
<p>(define (main args)<br />
  (let* ((partitions 12000)<br />
	 (increment (fl/ (fixnum-&gt;flonum partitions))))<br />
    (let y-loop ((y 0)<br />
		 (count 0))<br />
      (if (fx= partitions y)<br />
	  (* 4 (/ count (* partitions partitions)))<br />
	  (let ((b (fl* increment (fl+ (fixnum-&gt;flonum y) 0.5))))<br />
	    (let x-loop ((x 0)<br />
			 (count count))<br />
	      (if (fx= partitions x)<br />
		  (y-loop (fx+ y 1)<br />
			  count)<br />
		  (let ((a (fl* increment (fl+ (fixnum-&gt;flonum x) 0.5))))<br />
		    (if (flstring (exact-&gt;inexact (main &#8216;()))) &#8220;\n&#8221;))</p>
<p>:~&gt; gcc -O3 -Wall -o pic pic.c<br />
:~&gt; time ./pic<br />
Estimate of pi is: 3.14159492<br />
1.230u 0.000s 0:01.23 100.0%	0+0k 0+0io 0pf+0w<br />
:~&gt; gsc pi<br />
:~&gt; time gsi pi<br />
3.1415949166666666<br />
1.250u 0.000s 0:01.25 100.0%	0+0k 0+0io 0pf+0w</p>
]]></content:encoded>
	</item>
</channel>
</rss>

