Files
harbour-core/harbour/tests/memtst.prg
Viktor Szakats e788d6d3e8 2012-07-18 13:54 UTC+0200 Viktor Szakats (harbour syenar.net)
+ contrib/hbgt/tests
  + contrib/hbgt/tests/test.prg
  + contrib/hbmisc/tests/rtfclass.prg
  - tests/rtfclass.prg
  - tests/test10.prg
  - tests/testgt.prg
  * tests/ac_test.prg
  * tests/alias.prg
  * tests/begin.prg
  * tests/boxtest.prg
  * tests/cdow.prg
  * tests/clasinh.prg
  * tests/dates.prg
  * tests/dates2.prg
  * tests/dates3.prg
  * tests/dates4.prg
  * tests/ddate.prg
  * tests/debugtst.prg
  * tests/delimtst.prg
  * tests/devtest.prg
  * tests/disptest.prg
  * tests/foreach.prg
  * tests/gtstdtst.prg
  * tests/ipclnt.prg
  * tests/ipsvr.prg
  * tests/langapi.prg
  * tests/memtst.prg
  * tests/memvar.prg
  * tests/menutest.prg
  * tests/mousetst.prg
  * tests/multiarg.prg
  * tests/newrdd.prg
  * tests/nums.prg
  * tests/objarr.prg
  * tests/objasign.prg
  * tests/objects.prg
  * tests/omacro.prg
  * tests/onidle.prg
  * tests/os.prg
  * tests/output.prg
  * tests/overload.prg
  * tests/parexpr.prg
  * tests/passref.prg
  * tests/procline.prg
  * tests/procname.prg
  * tests/recursiv.prg
  * tests/returns.prg
  * tests/round.prg
  * tests/say.prg
  * tests/sbartest.prg
  * tests/scroll.prg
  * tests/sdf_test.prg
  * tests/seconds.prg
  * tests/server.prg
  * tests/set_num.prg
  * tests/set_test.prg
  * tests/setkeys.prg
  * tests/sound.prg
  * tests/speed.prg
  * tests/statfun.prg
  * tests/statics.prg
  * tests/statics1.prg
  * tests/statics2.prg
  * tests/statinit.prg
  * tests/strdelim.prg
  * tests/stripem.prg
  * tests/switch.prg
  * tests/symbolt.prg
  * tests/t1.prg
  * tests/tb1.prg
  * tests/testbrdb.prg
  * tests/testbrw.prg
  * tests/testcdx.prg
  * tests/testcls.prg
  * tests/testdbf.prg
  * tests/testdecl.prg
  * tests/testerro.prg
  * tests/testfor.prg
  * tests/testget.prg
  * tests/testhrb.prg
  * tests/testhtml.prg
  * tests/testidle.prg
  * tests/testmem.prg
  * tests/testpers.prg
  * tests/testtok.prg
  * tests/testwarn.prg
  * tests/tstalias.prg
  * tests/tstasort.prg
  * tests/tstblock.prg
  * tests/tstdbi.prg
  * tests/tstmacro.prg
  * tests/varparam.prg
  * tests/wvt_fs.prg
    * cleaning up tests
2012-07-18 12:00:10 +00:00

108 lines
2.1 KiB
Plaintext

/*
* $Id$
*/
/*
* Harbour Project source code:
* a small memory mangaer test code
*/
#include "simpleio.ch"
#define N_LOOPS 100000
#ifdef __HARBOUR__
#include "hbmemory.ch"
#endif
PROCEDURE Main()
local nCPUSec, nRealSec, i, a
#ifdef __HARBOUR__
if MEMORY( HB_MEM_USEDMAX ) != 0
?
? "Warning !!! Memory statistic enabled."
endif
#endif
?
? date(), time(), VERSION()+build_mode()+", "+OS()
?
? "testing single large memory blocks allocation and freeing..."
nRealSec := seconds()
nCPUSec := hb_secondsCPU()
for i := 1 to N_LOOPS
a := space( 50000 )
next
a := NIL
nCPUSec := hb_secondsCPU() - nCPUSec
nRealSec := seconds() - nRealSec
? " CPU time:", nCPUSec, "sec."
? "real time:", nRealSec, "sec."
?
? "testing many large memory blocks allocation and freeing..."
nRealSec := seconds()
nCPUSec := hb_secondsCPU()
a := array(100)
for i := 1 to N_LOOPS
a[ i % 100 + 1 ] := space( 50000 )
if i % 200 == 0
afill(a,"")
endif
next
a := NIL
nCPUSec := hb_secondsCPU() - nCPUSec
nRealSec := seconds() - nRealSec
? " CPU time:", nCPUSec, "sec."
? "real time:", nRealSec, "sec."
?
? "testing large memory block reallocation with intermediate allocations..."
? "Warning!!! some compilers may badly fail here"
wait
nRealSec := seconds()
nCPUSec := hb_secondsCPU()
a := {}
for i := 1 to N_LOOPS
aadd( a, {} )
if i%1000 == 0
?? i
endif
next
nCPUSec := hb_secondsCPU() - nCPUSec
nRealSec := seconds() - nRealSec
? " CPU time:", nCPUSec, "sec."
? "real time:", nRealSec, "sec."
wait
return
function build_mode()
#ifdef __CLIP__
return " (MT)"
#else
#ifdef __XHARBOUR__
return iif( HB_MULTITHREAD(), " (MT)", "" ) + ;
iif( MEMORY( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
#else
#ifdef __HARBOUR__
return iif( HB_MTVM(), " (MT)", "" ) + ;
iif( MEMORY( HB_MEM_USEDMAX ) != 0, " (FMSTAT)", "" )
#else
#ifdef __XPP__
return " (MT)"
#else
return ""
#endif
#endif
#endif
#endif
#if __HARBOUR__ < 0x010100
FUNCTION HB_MTVM()
RETURN .F.
#endif