Files
harbour-core/harbour/tests/speedstr.prg
Viktor Szakats 9f0c672127 2012-07-19 11:28 UTC+0200 Viktor Szakats (harbour syenar.net)
* tests/cursrtst.prg
  * tests/db_brows.prg
  * tests/debugtst.prg
  * tests/dirtest.prg
  * tests/foreach.prg
  * tests/funcarr.prg
  * tests/memvar.prg
  * tests/objarr.prg
  * tests/onidle.prg
  * tests/speedstr.prg
  * tests/speedtst.prg
  * tests/switch.prg
  * tests/testdbf.prg
  * tests/testdecl.prg
  * tests/testget.prg
    * formatting
2012-07-19 09:29:56 +00:00

78 lines
1.4 KiB
Plaintext

/*
* $Id$
*/
/*
* Harbour Project source code:
* speed test program for string concatenation by += operator
*
* Copyright 2011 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://harbour-project.org
*
*/
#define N_LOOP 200000
#ifndef __XHARBOUR__
#translate secondsCPU( => hb_secondsCPU(
#endif
#ifdef __XPP__
#translate secondsCPU( => seconds(
#endif
#ifdef __HARBOUR__
#include "hbclass.ch"
#endif
proc 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 += chr( i )
next
t := secondsCPU() - t
? "LOCAL +=", t, "sec."
t := secondsCPU()
for i := 1 to N_LOOP
s += chr( i )
next
t := secondsCPU() - t
? "STATIC +=", t, "sec."
t := secondsCPU()
for i := 1 to N_LOOP
s2[ 1 ] += chr( i )
next
t := secondsCPU() - t
? "ARRAY[] +=", t, "sec."
t := secondsCPU()
for i := 1 to N_LOOP
p += chr( i )
next
t := secondsCPU() - t
? "PRIVATE +=", t, "sec."
p := ""; s := "p"
t := secondsCPU()
for i := 1 to N_LOOP
&s += chr( i )
next
t := secondsCPU() - t
? "MACRO +=", t, "sec."
o := mycls():new(); o:v := ""
t := secondsCPU()
for i := 1 to N_LOOP
o:v += chr( i )
next
t := secondsCPU() - t
? "OBJECT:VAR +=", t, "sec."
wait
return
class mycls
exported:
var v
endclass