Re: Fortran decimal anyone?

From: David Frank (dave_frank_at_hotmail.com)
Date: 05/14/04


Date: Fri, 14 May 2004 12:18:15 GMT


"Mike Cowlishaw" <mfc@uk.ibm.com> wrote in message
news:c825v0$c6c$1@news.btv.ibm.com...
> David Frank wrote:
>> Mike,
>> re: your Telco Million call benchmark
>>
>> I will chime in for my fav language Fortran,
>> perhaps you can supply missing info in below scorecard?
>>
>> 1. Fortran 25 statements 3 sec to execute (David Frank)
>> [etc.]
>
> Hi .. yes, by using integers and manual scaling, it is easy to
> write a special-purpose piece of code for this that is very
> short and fast.
>
> But that's missing the point of the benchmark The benchmark
> is intended to estimate the overhead of the calculations when
> they are done in a straightforward and maintainable way.
>
> The actual total speed is uninteresting; as someone pointed
> out, the full application would be more complex and work
> on much larger quantities of data. What the benchmark
> does appear to do is match the behaviour of those large
> real applications in that one respect.
>
> Mike
>

re: straightforward and maintainable way..

That of course, is in the eye of the beholder.

Looking at your TELCO.C file below
You use 2 function statements each time a multiply is performed,
PLUS statements to invoke rounding required.
PLUS functions have 4 arguments, thats more straightforward?
PLUS none of your languages support overloading of the = + - * /
operators vs. fortran's ability to do p = time*brate syntax..
A plethora of keystrokes in order to get the most basic math done
is apt to be LESS-straightforward/maintainable in my view.

TELCO.c
<snip over 100 statements to get to the compute loop>

  /* Start of the by-number loop */
  for (numbers=0; ; numbers++) {
    // get next 8-byte packed decimal number
    readlen=fread(inpack, 1, INNUMLEN, inp);
    if (readlen<INNUMLEN) { // error or EOF
      frc=ferror(inp); // check for error
      // [note: ferror is single thread, but only this thread knows INP]
      if (frc!=0) printf("Error: cannot read file '%s'", filein);
      break; // [no message if EOF]
    }
    if (calc!=0) {
      calltype=((unsigned)inpack[INNUMLEN-1]>>4) & 0x01; // last bit

      // have packed decimal number; convert to working format
      decPackedToNumber(inpack, INNUMLEN, &inscale, &n);

      if (calltype==0) // p=r[c]*n
        decNumberMultiply(&p, &baserate, &n, &set);
      else
        decNumberMultiply(&p, &distrate, &n, &set);
      set.round=DEC_ROUND_HALF_EVEN; // round prices
      decNumberRescale(&p, &p, &mtwo, &set); // to x.xx

      if (tax!=0) {
        set.round=DEC_ROUND_DOWN; // truncate taxes
        decNumberMultiply(&b, &p, &basetax, &set); // b=p*0.0675
        decNumberRescale(&b, &b, &mtwo, &set); // to x.xx
        decNumberAdd(&sumB, &sumB, &b, &set); // sumB=sumB+b
        decNumberAdd(&t, &p, &b, &set); // t=p+b

        if (calltype!=0) {
          decNumberMultiply(&d, &p, &disttax, &set); // d=p*0.0341
          decNumberRescale(&d, &d, &mtwo, &set); // to x.xx
          decNumberAdd(&sumD, &sumD, &d, &set); // sumD=sumD+d
          decNumberAdd(&t, &t, &d, &set); // t=t+d
        }
      } else {
        t=p;
      }
      decNumberAdd(&sumT, &sumT, &t, &set); // sumT=sumT+t
      decNumberToString(&t, string);
      // printf("[%d] %d: %s\n", calltype, numbers, string);
    } else {
      strcpy(string, "0.77");
    }
    // [Adding CRLF is part of I/O, as other languages have WriteLine]
    strcat(string, "\r\n"); // Add CRLF
    len=strlen(string);
    urc=fwrite(string, 1, len, oup);
    if (urc!=len) {
      printf("Error: file '%s' could not be written", fileou);
      break;
    }



Relevant Pages

  • Re: Fortran decimal anyone?
    ... > I will chime in for my fav language Fortran, ... > perhaps you can supply missing info in below scorecard? ... But that's missing the point of the benchmark The benchmark ... Mike ...
    (comp.lang.fortran)
  • Re: Limiting closed port RST response from XXX to 200...
    ... Mike Silbersack wrote: ... |> On a server I'm benchmark testing, via local host, I'm getting Limiting ... What you should be asking is - why are 7500 junk packets per second ...
    (freebsd-hackers)
  • Re: TelCo "programming challenge" (update)
    ... Mike Cowlishaw wrote: ... >>that needs more inputs from fav language adherents.. ... > But that's missing the point of the benchmark The benchmark ... hardware on their Video Card to exploit the "standard" benchmark test, ...
    (comp.lang.cobol)
  • Re: Which method would be faster?
    ... [MIKE D] ... any benchmark or other test is going to be affected by ... the "power" of the PC, as well as other factors (network connection, et ...
    (microsoft.public.vb.general.discussion)