Files
harbour-core/tests/speedstr.prg
Viktor Szakats 58faf91453 2016-01-14 19:17 UTC+0100 Viktor Szakats (vszakats users.noreply.github.com)
* *
    % remove brandings and homepage [1] from copyright header. Pass 1 - using script.
      [1] nobody has access to it anymore AFAIK - and it's also just
          a redirect since long
    ! update url in copyright header
    ; this should make the diff between 3.4 and 3.2 easier to manage
2016-01-14 19:18:17 +01:00

79 lines
1.4 KiB
Plaintext

/*
* speed test program for string concatenation by += operator
*
* Copyright 2011 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
*
*/
#define N_LOOP 200000
#ifndef __XHARBOUR__
# translate secondsCPU( => hb_secondsCPU(
#endif
#ifdef __XPP__
# translate secondsCPU( => seconds(
#endif
#ifdef __HARBOUR__
# include "hbclass.ch"
#else
# translate hb_BChar( => Chr(
#endif
PROCEDURE Main()
MEMVAR p
LOCAL i, t
LOCAL l, o
STATIC s, s2[ 1 ]
PRIVATE p
p := s2[ 1 ] := s := l := ""
t := secondsCPU()
FOR i := 1 TO N_LOOP
l += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "LOCAL +=", t, "sec."
t := secondsCPU()
FOR i := 1 TO N_LOOP
s += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "STATIC +=", t, "sec."
t := secondsCPU()
FOR i := 1 TO N_LOOP
s2[ 1 ] += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "ARRAY[] +=", t, "sec."
t := secondsCPU()
FOR i := 1 TO N_LOOP
p += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "PRIVATE +=", t, "sec."
p := ""; s := "p"
t := secondsCPU()
FOR i := 1 TO N_LOOP
&s += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "MACRO +=", t, "sec."
o := mycls():new(); o:v := ""
t := secondsCPU()
FOR i := 1 TO N_LOOP
o:v += hb_BChar( i )
NEXT
t := secondsCPU() - t
? "OBJECT:VAR +=", t, "sec."
WAIT
RETURN
CLASS mycls
EXPORTED:
VAR v
ENDCLASS