At 11:14 +0400 98/09/14, S.D.Mechveliani wrote:
>Here is some simple benchmark for  Int vs Integer  performance.
>
>In the system i use, it gives the time ratio Integer/Int
>(for the whole task)  = 4.5.


At 23:13 +0100 98/09/13, Simon Marlow wrote:
>The plan is to use something like
>
>       data Integer = Small Int# | Big { ... }
>
>where '...' is the GMP representation.  You then need a full set of
>overflow-detecting primitive operations on Int.  I've done a few
>experiments with using gcc's 'long long' type to implement these
>portably (well, portably across 32-bit architectures...), and it seems
>possible.
>
>The common case of applying a dyadic operation to small Integers would
>then be pretty close in performance to that of Int (a couple of
>indirect jumps, and a test/branch for the overflow detection, to be
>precise).

  The real difficulty to upper the Integer/Int ratio of 4.5 for integers
fitting into a word is to minimize those overflow checks. So this part
should be written in assembler, I think.

  I can mention that an idea for C++ I have is to write
    class Integer {
        int low;      // The length for large integers.
        int* high;    // 0 for small integrers.
    public:
        ...
    };
One then ends up with the same overflow checks as above, but on the same
time ensures that dynamic memory allocation is not used for small integers
and that integers are packed efficiently.

  Hans Aberg
                  * Email: Hans Aberg <mailto:[EMAIL PROTECTED]>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>



Reply via email to