Thanks Raul, I added your ‘tail' implementation to the code and it works without issue. The KJV text is listed in reverse line order in the output file.
benchmarks '' sumloop: 0.227858 8.39149e6 sumj: 0.000171 1.04986e6 ack: 2e_6 721472 array1: 5.6e_5 1.05107e6 array1t: 4.8e_5 1.05107e6 string1: 0.003969 2.88634e6 cat: 0.01474 2.51685e7 wc: 0.295076 1.58152e8 tail: 0.065197 3.77133e7 sum1: 0.12709 4.04989e7 sum1j: 0.000547 1.18086e6 I have placed the code on GitHub: https://github.com/tmcguirefl/JBenchmarks The scheme folks have put together a large set of benchmarks at: https://www.ccs.neu.edu/home/will/Twobit/benchmarksAboutR6.html When time permits I will go through them and implement the ones that would be J appropriate (some do symbolic differentiation which would be nontrivial for me to code into J). Tom McGuire > On May 18, 2021, at 9:04 PM, Raul Miller <rauldmil...@gmail.com> wrote: > > 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 > <mailto: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 >> <http://www.jsoftware.com/forums.htm> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > <http://www.jsoftware.com/forums.htm> ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm