C Extension Benchmarks

80 views
Skip to first unread message

Timothy Baldridge

unread,
Dec 19, 2012, 9:51:34 AM12/19/12
to clojure...@googlegroups.com
In order to get an idea of what sort of performance gains we'd see by going with Clojure-py on LLVM via Python extension modules, I ran a simple fib benchmark:

9227465
Time 5.65887999535 # Pure Python
9227465
Time 3.04140090942 # Simple Native compiled
9227465
Time 1.86417007446 # Call optimized
9227465
Time 0.0701291561127 # Type hinted. 

Times are in sec. Source is here https://gist.github.com/4337160

So simply translating clojure code to native code using Python C APIs, should result in almost a 2x performance boost. Optimizing how native functions call each other, should result in another 2x boost. Supporting type hints will result in about a 72x boost (and is actually faster than clojure-jvm at that point, from what I can tell). 

So this looks hopeful. Even with the worst case situation, we should at least be quite a bit faster than python. 

Timothy

Konrad Hinsen

unread,
Dec 19, 2012, 12:31:08 PM12/19/12
to clojure...@googlegroups.com
--On 19 décembre 2012 07:51:34 -0700 Timothy Baldridge
<tbald...@gmail.com> wrote:

> So simply translating clojure code to native code using Python C APIs,
> should result in almost a 2x performance boost. Optimizing how native

I suppose you could get less of a boost for code that does more work inside
Python objects' methods. At least that's my experience with compiling plain
Python code using Cython. Your example uses very simple Python methods
(integer arithmetic), so the interpretation overhead in your function is
relatively more important.

Konrad.
Reply all
Reply to author
Forward
0 new messages