Here's the tail benchmark written in J:

tail=: 4 : 0
  (;|.<;.2 freads x) fwrites y
)

This is based on my reading of the C implementation of the tail
benchmark vs the cat benchmark, and on the cat benchmark in this J
implementation, except that I have failed to reproduce a bug in the C
implementation which shows up when the file contains very long lines
and instead I have assumed that the file ends in a newline (which is a
valid assumption for the gutenberg kjv bible).

Let me know if you think I have made a mistake here.

Thanks,

--
Raul

On Tue, May 18, 2021 at 7:02 PM Thomas McGuire <tmcguir...@gmail.com> wrote:
>
> I was going over Devon McCormick's notes from the latest NYCJUG meeting. 
> There was a discussion about Benchmarks with an example of the Kernighan/Van 
> Wyk benchmarks in LISP/Scheme. Devon had made the comment that for most 
> things people use J for that correctness overshadowed performance.
>
> The K/VW benchmarks were originally made for C and seem to test looping 
> controls and memory allocation which at a time of low memory minicomputers 
> and PCs, coupled with multiple available C compilers, made the benchmarks a 
> nice way of comparing compiler implementations as well as new processor speed.
>
> However it seemed like a simple project to exercise my J programming skills 
> with so I have attached the program to this email.
>
> Note: you will need to download the King James Version of the Bible from 
> project Guttenburg (not included with the attachment) to run the full 
> benchmarks. I also created my own file of floating point numbers to sum 
> (routine to create a file of random floats is included). I have added some 
> routines to accomplish similar functionality in the way I would do it in J 
> (at least for my mere mortal understanding of J).
>
> Running on my mac book pro (2016 with 2.9 Ghz Quad core I7) the results are:
>
>    benchmarks ''
> sumloop: 0.214383 8.39149e6
> sumj: 0.000162 1.04986e6
> ack: 4e_6 721472
> array1: 0.000578 1.05107e6
> array1t: 2.5e_5 1.05107e6
> string1: 0.003237 2.88634e6
> cat: 0.014234 2.51685e7
> wc: 0.302383 1.58152e8
> sum1: 0.124006 4.04989e7
> sum1j: 0.000956 1.18086e6
>
> thought I would share
>
> Tom McGuire
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to