C Collection of code snippets by Arne Vajhøj 
C (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
      program native_test
      integer*4 REP
      parameter (REP = 10)
      integer*4 i, scale
      character*256 cmdlin
      integer*4 cmdlinlen
      write(*,*) 'Fortran:'
      call lib$get_foreign(cmdlin,,cmdlinlen)
      if(cmdlinlen.gt.0) then
        read(cmdlin(1:cmdlinlen),'(I)') scale
      else
        scale = 1
      end if
      do 100 i =1,REP
        call testint(scale)
100   continue
      do 200 i =1,REP
        call testfp(scale)
200   continue
      do 300 i =1,REP
        call teststr(scale)
300   continue
      end
c
      subroutine testint(scale)
      integer*4 scale
      integer*4 NINT,N
      parameter (NINT = 10000, N = 1000000)
      integer*4 i, j, nintscale, sum
      integer*8 t1, t2
      nintscale = NINT / scale
      call sys$gettim(t1)
      do 200 i = 1, nintscale
        sum = i - 1
        do 100 j = 1, N
          sum = ((sum + 1) * 2 + 1) / 2
100     continue
        if(sum.ne.(i - 1 + N)) then
          write(*,*) 'Integer test error'
          stop
        end if
200   continue
      call sys$gettim(t2)
      call printres(t1, t2, nintscale, N, 'integer operations')
      end
c
      subroutine testfp(scale)
      integer*4 scale
      integer*4 NFP, N
      parameter (NFP = 1000, N = 1000000)
      integer*4 i, j, nfpscale
      real*8 sum
      integer*8 t1, t2
      nfpscale = NFP / scale
      call sys$gettim(t1)
      do 200 i = 1, nfpscale
        sum = i - 1
        do 100 j = 1, N
          sum = ((sum + 1) * 2 + 1) / 2
100     continue
        if(abs(sum - (i - 1 + 1.5 * N)).gt.1) then
          write(*,*) 'Floating point test error'
          stop
        end if
200   continue
      call sys$gettim(t2)
      call printres(t1, t2, nfpscale, N, 'floating point operations')
      end
c
      subroutine teststr(scale)
      integer*4 scale
      integer*4 NSTR, N, VMS_FACTOR
      character*26 ALFA
      parameter (NSTR = 100, N = 1000000,
     +           ALFA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', VMS_FACTOR = 100)
      integer*4 i, j, nstrscale, slen, ix, ix1, ix2, ix1m, ix2m
      character*52 s
      character*32767 buf
      integer*8 t1, t2
      nstrscale = NSTR / scale
      call sys$gettim(t1)
      do 200 i = 1, nstrscale * VMS_FACTOR
        slen = 0
        do 100 j = 1, N / VMS_FACTOR, 10
          s = ALFA // ALFA
          ix = mod(i - 1 + j - 1, len(ALFA))
          buf(slen:slen+9) = s(ix + 1:ix + 1) // s(ix + 2:ix + 3) //
     +      s(ix + 4: ix + 6) // s(ix + 7:ix + 10)
          slen = slen + 10
100     continue
        ix1 = (N / VMS_FACTOR) / 3
        ix2 = 2 * (N / VMS_FACTOR) / 3
        ix1m = mod(i - 1 + ix1, len(ALFA)) + 1
        ix2m = mod(i - 1 + ix2, len(ALFA)) + 1
        if((slen.ne.(N / VMS_FACTOR)).or.
     +     (buf(ix1:ix1).ne.ALFA(ix1m:ix1m)).or.
     +     (buf(ix2:ix2).ne.ALFA(ix2m:ix2m))) then
          write(*,*) 'String test error'
          stop
        end if
200   continue
      call sys$gettim(t2)
      call printres(t1, t2, nstrscale, N / 10, 'string operations')
      end
c
      subroutine printres(t1, t2, n1, n2, ops)
      integer*8 t1, t2
      integer*4 n1, n2
      character*(*) ops
      real*8 xperf
      xperf = n1 * 1.0 * n2 / ((t2 - t1) / 10000000.0)
      write(*,'(1x,f9.4,9h million ,a,11h per second)')
     +  (xperf / 1000000), ops
      end
