Humble benchmark (fisher's exact test)

bachmeier no at spam.net
Sat Aug 14 12:48:05 UTC 2021


On Saturday, 14 August 2021 at 02:19:02 UTC, Ki Rill wrote:
> It's a simple benchmark examining:
> * execution time (sec)
> * memory consumption (kb)
> * binary size (kb)
> * conciseness of a programming language (lines of code)
>
> [Link](https://github.com/rillki/humble-benchmarks/tree/main/fishers-exact-test)

I'm skeptical that you're measuring what you think you're 
measuring. I say this because the R version shouldn't be that 
much slower than the C version. All that happens when you call 
`fisher.test` is that it checks which case it's handling and then 
calls the builtin C function. For example, [this 
line](https://github.com/wch/r-source/blob/79298c499218846d14500255efd622b5021c10ec/src/library/stats/R/fisher.test.R#L120).

More likely a chunk of your C code is being eliminated by the 
optimizer. Another thing is that printing to the screen is much 
slower in R than in C. You shouldn't benchmark printing to the 
screen since that is not something you would ever do in practice. 
If you really want performance, you can determine which case 
applies to your code and then make the underlying `.Call` 
yourself. If you don't do that, you're comparing Fisher's exact 
test against a routine that does a lot more than Fisher's exact 
test. In any event, you're not comparing against an R 
implementation of this test.


More information about the Digitalmars-d mailing list