Let f be a function that depends on every byte of
its argument(s).  >:y and x+y are examples of
such a function, and {.y is not.  The number of 
cycles per byte (CPB) for f is 
   n %~ g * 6!:2 '  f y'
   n %~ g * 6!:2 'x f y'
where n is the number of bytes in dense x, y, 
or the result x f y, whichever is the greatest;
and g is the clock rate of the CPU.

For example, on an ordinary (not overclocked) 
2.2 Ghz AMD 3200+ machine,

   (1*m) %~ 2.2e9 * 6!:2 'm$0'   [ m=: 1e7
2.34726
   (4*m) %~ 2.2e9 * 6!:2 'm$2'   [ m=: 1e7
2.3531
   (8*m) %~ 2.2e9 * 6!:2 'm$0.2' [ m=: 1e7
2.35242

The CPB for $ is approximately 2.35.

Some others:

   x=: 1e7 [EMAIL PROTECTED] 2
   y=: 1e7 [EMAIL PROTECTED] 2
   (#x)   %~ 2.2e9 * 6!:2 'x+.y' 
4.85849
   (4*#x) %~ 2.2e9 * 6!:2 'x+y'
2.69899
   (4*#x) %~ 2.2e9 * 6!:2 '/:x'
6.04693
   (#x)   %~ 2.2e9 * 6!:2 '/:~x'
3.09869

Here is something for you to think about
between eating turkeys and scoffing treats and 
and stuffing stuffings and opening presents:  
What is the smallest cycles per byte that you can 
achieve in J?  My current champion is less than 1. 
(Remember, the function must depend on every byte 
of its argument.)  



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to