a little speed comparison

240 views
Skip to first unread message

Peter

unread,
May 20, 2018, 3:59:29 PM5/20/18
to chez-scheme
There's a C++ program I use regularly to look for copying between documents - the program's called Ferret.
The program has stayed in C++ because nothing else had come close in speed and memory use, until ...
I converted the program into Scheme, both for Chez and for R7RS implementations.

The R7RS implementations performed like scripting languages tend to do when compared with C++: the time/memory use soon became too slow for me to use regularly.

But the Chez Scheme version ... not only competed with the C++ one, but has it soundly beat. For processing 4 million words, Chez Scheme takes 17.3 seconds to C++'s 23: a 25% improvement!

Although I did this last year I have only now posted something, so if you want some more details and graphs(!), see https://petercrlane.github.io/2017/06/06/speed-test.html

Andy Keep

unread,
May 22, 2018, 10:19:46 PM5/22/18
to chez-scheme
Very cool!  Always good to see Chez Scheme comparing well.

-andy:)

john lynch

unread,
May 22, 2018, 10:43:51 PM5/22/18
to chez-scheme
I'm reluctant to post this but I severely doubt this test.  I wasn't going to say anything but Andy posted so I guess people are buying the test as valid.

1.  Its only a test of your scheme vs your C++

2.  I had a quick look at your get & you mentioned that the C was wrapped in Ruby or something.  So are we testing C++ or is it severly polluted by ruby ?

Every time we see a "better than C" or "better than C++" ... its like the Lisps or Haskell vs the 2 Cs ... if someone does the work to replicate then it almost always proves problematic. 

Andy Keep

unread,
May 22, 2018, 10:48:43 PM5/22/18
to chez-scheme, john lynch
Perhaps I should have studied the code before commenting :)

I admit I mostly looked at the graphs and not the code.  I’m assuming the comparison with other scheme implementations is still valid, since I’m assuming this code is close to identical?

-andy:)
--
You received this message because you are subscribed to the Google Groups "chez-scheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chez-scheme...@googlegroups.com.
To post to this group, send email to chez-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chez-scheme/20690ef0-e000-4f4c-860c-e3c696a18675%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter

unread,
May 23, 2018, 6:44:43 AM5/23/18
to chez-scheme

On May 22, 2018 at 10:43:53 PM, john lynch (mjohn...@gmail.com) wrote:

I'm reluctant to post this but I severely doubt this test.  I wasn't going to say anything but Andy posted so I guess people are buying the test as valid.

1.  Its only a test of your scheme vs your C++

2.  I had a quick look at your get & you mentioned that the C was wrapped in Ruby or something.  So are we testing C++ or is it severly polluted by ruby ?

I quite agree with the skepticism - it's true this is just my code, and that there is a ruby wrapper. Although I do believe Chez Scheme has done well against my C++ code.

Just to explain what's happening, the program is not complicated:

1. Read in a bunch of text from files, strip out information on words etc, and store data in hash tables
2. Collate some stats
3. Print out

Part 1 is a single call out to the C++ core, and timing just that call:

Call C++: 23/05/2018 10:45:12
End C++: 23/05/2018 10:45:31

A time of around 19 seconds in a total runtime of 21s.

The Chez Scheme program finishes everything in 16s.

I'm not sure how the times are so close - Chez perhaps has very good file-handling and hash-table support, especially compared to other Schemes.



Amirouche Boubekki

unread,
May 24, 2018, 9:48:52 AM5/24/18
to chez-scheme
I made a small comparison between Chez, CPython and PyPy (and Guile Scheme but I don't have the result right now for that part).

I coded a s-expr reader using parser combinators in Python and Scheme. The main difference between the Scheme implementation and the Python implementation is that the Python implementation rely on exceptions.


The results the speed comparison:

- chez read: 0
- chez cx read: 7
- cpython cx read: 234.32910704612732
- pypy cx read: 17.128060340881348

'chez read' is the native chez 'read' procedure.

The virtual memory used is as follow:

- chez read: 40MB
- chez cx read: 40MB
- cpython cx read: 9MB
- pypy cx read: 90MB


Cheers,


Amirouche

Amirouche Boubekki

unread,
May 24, 2018, 9:54:14 AM5/24/18
to chez-scheme
Here is the results of another run including Guile Scheme. All those were done on another machine...

- guile read: 3s 11MB
- guile cx read: 63s 18MB
- chez read: 0s 45MB
- chez cx read: 7s 40MB
- cpython cx read: 247.4394781589508s 9MB
- pypy cx read: 22.92888855934143s 90MB

Seems like guile consume less memory but is 10 times slower.
Reply all
Reply to author
Forward
0 new messages