Live data from Hacker News

Make Lisp 15x faster than Python or 4x faster than Java

blog.postabon.com

31–40 of 100 posts

Re: Make Lisp 15x faster than Python or 4x faster than Java

#31
post #30
post #13

How about benchmarking the python code with NumPy?

My understanding is that you have to rewrite your code to take advantage of NumPy. Unfortunately, I've never used NumPy before, so I don't know how to do so. However, if you'd like to modify my code to do so I'd be happy to rerun the test and publish the results.

[deleted]

Re: Make Lisp 15x faster than Python or 4x faster than Java

#32
post #24

> All the benchmarks were run 5x each on the same Debian machine I refer the honourable gentlman to Zed Shaw's "Programmers Need To Learn Statistics Or I Will Kill Them All" http://www.zedshaw.com/essays/programmer_stats.html

I'm actually a mathematician by training ;-) I ran all tests 5 times each, and averaged the results. Each of the results for each of the tests were within 2% of each other, and the machine wasn't used for anything else while the tests were running. I know it's not perfect, but I don't see any obvious sources of error ... I did provide all the source, so you're welcome to verify my results.

I refer the honourable gentleman to the answer I gave a few moments ago :)

Re: Make Lisp 15x faster than Python or 4x faster than Java

#33
post #31
post #30

Earlier quoted context omitted.

My understanding is that you have to rewrite your code to take advantage of NumPy. Unfortunately, I've never used NumPy before, so I don't know how to do so. However, if you'd like to modify my code to do so I'd be happy to rerun the test and publish the results.

[deleted]

Yes ... but I don't know how to.

If you care to do so, I'll be happy to include the results.

Re: Make Lisp 15x faster than Python or 4x faster than Java

#35
post #7

Are people still calling Lisp slow in 2010? That was somewhat true when most programming was done in C. Plenty of languages slower than Lisp have risen to popularity since then.

Indeed, I thought it was always much faster:

http://shootout.alioth.debian.org/u32/benchmark.php?test=all...

One of the guys behind R is also looking at moving to a LISP base after considering python:

http://www.springerlink.com/content/v38u176xp7j562m3/

That said, I will stick with python as I am not a programmer by profession and can't deal with a plethora of languages when I have a good swiss army knife as it is.

Re: Make Lisp 15x faster than Python or 4x faster than Java

#37
post #34

Is java known to be (about) 4x faster than python?

4x is low: http://shootout.alioth.debian.org/u32q/benchmark.php?test=al... Roughly speaking, anything time-critical needs to be done in c.

Thanks! You guys rock! Also, would you therefore guess most of Google's search engine is written in C?

Re: Make Lisp 15x faster than Python or 4x faster than Java

#39
The result of the distance() function is unused and can be optimized away by the compiler. Runs in 0.04s with LuaJIT 2.0. No type declarations needed. :-)

    local radius = 6371

    local function distance(latA, lngA, latB, lngB)
      local latAr = math.rad(latA)
      local lngAr = math.rad(lngA)
      local latBr = math.rad(latB)
      local lngBr = math.rad(lngB)

      local deltaLat = latBr - latAr
      local deltaLng = lngBr - lngAr

      return radius * 2 * math.asin(math.sqrt(
              math.sin(deltaLat/2)^2 + math.cos(latAr)
              * math.cos(latBr) * (math.sin(deltaLng/2)^2)))
    end

    local start = os.clock()

    for latA=-90,90,2.5 do
      for lngA=-90,90,2.5 do
        for latB=-90,90,2.5 do
          for lngB=-90,90,2.5 do
            distance(latA, lngA, latB, lngB)
          end
        end
      end
    end

    local stop = os.clock()
    print(stop-start)

Re: Make Lisp 15x faster than Python or 4x faster than Java

#40
post #24

> All the benchmarks were run 5x each on the same Debian machine I refer the honourable gentlman to Zed Shaw's "Programmers Need To Learn Statistics Or I Will Kill Them All" http://www.zedshaw.com/essays/programmer_stats.html

I'm actually a mathematician by training ;-) I ran all tests 5 times each, and averaged the results. Each of the results for each of the tests were within 2% of each other, and the machine wasn't used for anything else while the tests were running. I know it's not perfect, but I don't see any obvious sources of error ... I did provide all the source, so you're welcome to verify my results.

It shows, you are comparing optomized LISP with unoptomized Java and C. Java has a long startup process so it is relativly faster on 20 second benchmarks than sub second ones. As to C, it does what you tell it do do, so the compiler needs a little more handholding. I suspect LISP's compiler is not acctually doing the computations because they are never used, granted I have not really looked into it.
Post reply on HN