- Speed test. Obfuscation

From: Campbell, Robert D (SELEX) (UK Edinburgh) <"Campbell,>
Date: Mon, 6 Nov 2006 13:25:31 -0000

----boundary-LibPST-iamunique-1605591794_-_-
Content-type: text/plain




I have used a simple CPU / Maths speed test for a while.

It does not attempt to capture cache effects. While these can certainly
be large,
they also seem to be quite variable & unpredictable, so I doubt if
anything
can capture them reliably. Anyway this routine has seemed to give
indicative
performance metrics quite reliably for our kind of 'big' sums.

The algorithm in BlackBox:

PROCEDURE DoReal (trials : INTEGER);
  CONST
    pi = 3.14159265358979323846;
  VAR
    i, n : INTEGER;
    con, sum : REAL;
  BEGIN
    f.Str ('Number of trials = '); f.IntComma (trials, 0, 3); f.Ln;
    Timer.Reset;

    con := pi / 180.;

    FOR n := 1 TO trials DO
      sum := 0.;
      FOR i := 1 TO 100 DO
        sum := sum + Math.Sin (con * i)
      END
    END;

    Timer.Mark;
    f.Str ('Con = '); f.RealComma (con, 20, 15, 5, ','); f.Ln;
    f.Str ('Sum = '); f.RealComma (Sum, 20, 15, 5, ','); f.Str ('
in');
    Timer.WrtMark (f, TRUE)
  END DoReal;


(In this code 'f' is something that knows how to write to the Log, and
Timer
is a Module that can do simple timing tasks - the details are not
significant.)


One of my old results is for an early (1992 I think) DEC VAXstation &
FORTRAN:
  5.75 secs for 1000 trials.

One of my slow results was for an 8 MHz Motorola 68000 with software
floating point:
  687 secs for 1000 trials. (I actually used that machine a lot!)

One of my interesting results was for Maple:
  Very slow, but it got the (exactly) correct answer: a page of A4
involving root 2's,
  root 3's, root 5's, and lots of pi's.

Anyway about today's hardware. We have been considering .NET and
recently made these measurements:

        Visual Basic 6, compiled, pre .NET : 10.6 sec for 1 million
trials.
        Visual Basic.NET (code embedded) : 4.9 sec for 1 million
trials.
        Visual Basic.NET (calling a C# dll)): 5.5 sec for 1 million
trials.


        C#.NET (code embedded)) : 6.4 sec for 1 million trials.
        C#.NET (calling a C# dll)): 5.5 sec for 1 million trials.
        C++.NET (code embedded)) : 5.3 sec for 1 million trials.


        Matlab: 90 secs for 1 million trials (time scaled from a
different machine)


        BlackBox: 6.4 sec for 1 million trials.
        Gardens Point Component Pascal : About 5.5 secs - I have lost
the exact time.




Notes:
  1 - All results (except Maple) 64-bit floating point.

  2 - To be fair to Matlab (although I don't know why I should be!) you
can recover almost all the speed if:
  a) You can
&
  b) you can be bothered
to rewite the algorithm in 'Vectorised' form.

  3 - It would be interesting to have some comparable Java timings.
Informally
I think it is generally comparable, BUT it's trig routines do silly, and
very slow,
things if the angle is far outside the range +/- pi.


Cheers

Robert


********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

--- BlackBox
--- send subject HELP or UNSUBSCRIBE to blackbox{([at]})nowhere.xy


----boundary-LibPST-iamunique-1605591794_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"

e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFxwYXINClxwYXINClxwYXINCkkgaGF2ZSB1c2Vk
IGEgc2ltcGxlIENQVSAvIE1hdGhzIHNwZWVkIHRlc3QgZm9yIGEgd2hpbGUuXHBhcg0KXHBhcg0K
SXQgZG9lcyBub3QgYXR0ZW1wdCB0byBjYXB0dXJlIGNhY2hlIGVmZmVjdHMuIFdoaWxl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zXHBh
cg0KXHBhcg0KUm9iZXJ0XHBhcg0KXHBhcg0KXHBhcg0KKioqKioqKioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKipccGFyDQpUaGlzIGVt
YWlsIGFuZCBhbnkgYXR0YWNobWVudHMgYXJlIGNvbmZpZGVudGlhbCB0byB0aGUgaW50ZW5kZWRc
cGFyDQpyZWNpcGllbnQgYW5kIG1heSBhbHNvIGJlIHByaXZpbGVnZWQuIElmIHlvdSBhcmUgbm90
IHRoZSBpbnRlbmRlZFxwYXINCnJlY2lwaWVudCBwbGVhc2UgZGVsZXRlIGl0IGZyb20geW91ciBz
eXN0ZW0gYW5kIG5vdGlmeSB0aGUgc2VuZGVyLlxwYXINCllvdSBzaG91bGQgbm90IGNvcHkgaXQg
b3IgdXNlIGl0IGZvciBhbnkgcHVycG9zZSBub3IgZGlzY2xvc2Ugb3JccGFyDQpkaXN0cmlidXRl
IGl0cyBjb250ZW50cyB0byBhbnkgb3RoZXIgcGVyc29uLlxwYXINCioqKioqKioqKioqKioqKioq
KioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqXHBhcg0K
XHBhcg0KLS0tIEJsYWNrQm94XHBhcg0KLS0tIHNlbmQgc3ViamVjdCBIRUxQIG9yIFVOU1VCU0NS
SUJFIHRvIGJsYWNrYm94QG9iZXJvbi5jaH19AHJvbi5jaFxwYXI

----boundary-LibPST-iamunique-1605591794_-_---
Received on Mon Nov 06 2006 - 14:25:31 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:32:08 UTC