[Info-vax] Python for x86?

Arne Vajhøj arne at vajhoej.dk
Wed May 3 11:45:15 EDT 2023


On 5/2/2023 1:27 PM, Simon Clubley wrote:
> On 2023-05-01, Arne Vajhøj <arne at vajhoej.dk> wrote:
>> String operations (*)
>>                                   Alpha sim         Itanium
>>                                   (no JIT)          (older)
>> C                               0.076             1.94
>> Pascal                          0.005             0.32
>> Fortran                         0.002             0.07
>> Basic                           0.039             1.31
>> Ada (gnat make)                 0.005             -
>> Ada (gnat make -gnatp "-O3")    0.005             -
>> Java 5                          0.033             -
>> Java 8                          -                 1.76
>> Python 2                        0.005             -
>> Python 3                        -                 0.65
>>
>> *) string operations are done "natural", which means that they are done
>>      different in different languages.

> std::string would be interesting here if you have access to a C++ compiler.

C++ on Alpha simulator gives 0.005.

> What string operations are you performing ? Is it simple concatenation or
> something else ? The number of concatenations versus the size of each
> concatenation could also make a difference, at least for the dynamically
> allocated strings.

It is concatanations and substring operations.

VMS Pascal version:

const
     ALFA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
     VMS_FACTOR = 100;

procedure teststr(scale : integer);

var
     i, j, nstrscale, ix, ix1, ix2 : integer;
     s, buf : string;
     t1, t2 : Cardinal;

begin
     nstrscale := NSTR div scale;
     t1 := Clock;
     for i := 1 to nstrscale * VMS_FACTOR do begin
         buf := '';
         for j := 1 to ((N div VMS_FACTOR) div 10) do begin
             s := ALFA + ALFA;
             ix := (i - 1 + 10 * (j - 1)) mod length(ALFA);
             buf := buf + substr(s, ix + 1, 1) + substr(s, ix + 2, 2) + 
substr(s, ix + 4, 3) + substr(s, ix + 7, 4);
         end;
         ix1 := (N div VMS_FACTOR) div 3;
         ix2 := 2 * (N div VMS_FACTOR) div 3;
         if (length(buf) <> (N div VMS_FACTOR)) or
            (buf[ix1] <> ALFA[((i - 1 + ix1 - 1) mod length(ALFA)) + 1]) or
            (buf[ix2] <> ALFA[((i - 1 + ix2 - 1) mod length(ALFA)) + 1]) 
then begin
             writeln('String test error');
             halt;
         end;
     end;
     t2 := Clock;
     printres(t1, t2, nstrscale, N div 10, 'string operations');
end;

Arne





More information about the Info-vax mailing list