Files
harbour-core/harbour/tests/memtst.prg
Viktor Szakats 15b49556a2 2008-09-24 00:18 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* tests/memtst.prg
    + Added #include "simpleio.ch" to allow output redirection.

  * bin/bld.bat
  * bin/bld_os2.cmd
    * Removed any HB_GT_LIB "selection" logic. Selection is to 
      be done from source code, from now on all supported core GTs 
      are included in the lib list.
    * Few other minor cleanups.

  * source/vm/cmdarg.c
    * Commented code turned into HB_C52_STRICT branch.

  * source/vm/vmmt/Makefile
    ! Fixed cemgw -> mingwce

  * config/dos/global.cf
  * config/os2/global.cf
  * config/w32/global.cf
    % Removed unnecessary logic to select default GT. This is 
      done in Harbour source code now.

  ; TOFIX: After MT changes, mingw32 build gives this new error:
           make: *** mainstd: No such file or directory.  Stop.
           make[3]: *** [first] Error 2
           make[2]: *** [first] Error 2
2008-09-23 22:24:26 +00:00

108 lines
2.0 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
proc 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 := secondsCPU()
for i := 1 to N_LOOPS
a := space( 50000 )
next
a := NIL
nCPUSec := secondsCPU() - nCPUSec
nRealSec := seconds() - nRealSec
? " CPU time:", nCPUSec, "sec."
? "real time:", nRealSec, "sec."
?
? "testing many large memory blocks allocation and freeing..."
nRealSec := seconds()
nCPUSec := 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 := 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 := secondsCPU()
a := {}
for i := 1 to N_LOOPS
aadd( a, {} )
if i%1000 == 0
?? i
endif
next
nCPUSec := 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