2

I am used to benchmark Haskell functions via AutoBench but I haven't found so far any info about comparing Haskell and C with it.

In particular, I need to benchmark 2 functions and feed them with a random Int list (or array in C). From what I have seen people often compare the runtime of functions with the time unix command (which seems to me completely wrong if you want to get a precise benchmark).

Does anyone know a way or have a suggestion to benchmark functions from these 2 languages via AutoBench?

Gianmarco
  • 69
  • 1
  • 3
  • 1
    *AutoBench is a tool for comparing the time performance of two or more Haskell programs* - this is from its description. So it is for comparing Haskell vs Haskell. Perhaps you can write Haskell wrapper for C function using the [Foreign Function interface](https://wiki.haskell.org/Foreign_Function_Interface) – Eugene Sh. Oct 07 '20 at 20:57
  • @EugeneSh. I tried. The problem I am facing is that marshalling adds a considerable amount of overhead just to C functions and as I need a common interface from which infer input cases, I haven't come up with a solution. – Gianmarco Oct 07 '20 at 21:51
  • 1
    Could you stick the data in pinned arrays and have both Haskell and C functions use that? You'll have to change your Haskell functions to use arrays instead of lists, but that may well be a performance win anyway. – dfeuer Oct 08 '20 at 00:47
  • @dfeuer Yes it would be a solution but in my case, I have to compare 2 Quicksort versions to point out how linked lists can change performances and working with arrays would change the result. It is a very rare case... – Gianmarco Oct 08 '20 at 01:05
  • 1
    Perhaps you are looking for something like this? https://github.com/lehins/haskell-quicksort which has a comparison of quicksort in Haskell (both arrays and lists). There is also comparison to C implementation over FFI which is currently commented out because naive C implementation doesn't handle an already sorted array too well. – lehins Oct 10 '20 at 17:38
  • 1
    @Gianmarco, please let me know if you'll be able to beat the version that uses `massiv` ;) – lehins Oct 10 '20 at 17:42

0 Answers0