Files
harbour-core/harbour/tests/memtst.prg
Viktor Szakats fe38540ca2 2010-02-20 12:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbsetup.ch
  * src/common/hbverdsp.c
    - Deleted HB_COMPAT_FLAGSHIP, HB_COMPAT_FOXPRO.

  * include/hbextern.ch
  * src/rtl/seconds.c
    + Added HB_SECONDSCPU()
      (native Harbour version of FlagShip specific SECONDSCPU())

  * tests/memtst.prg
  * tests/speedold.prg
  * tests/speedtst.prg
  * tests/vidtest.prg
    * Changed to use HB_SECONDSCPU().
    + Added translation from SECONDSCPU() to HB_SECONDSCPU() when
      built for FlagShip (where applicable).

  * include/hbextern.ch
  * src/rtl/Makefile
  - src/rtl/strpeek.c
  - src/rtl/secondfs.c
  * contrib/Makefile
  + contrib/hbfship
  + contrib/hbfship/Makefile
  + contrib/hbfship/hbfship.hbc
  + contrib/hbfship/secondfs.c
  + contrib/hbfship/strpeek.c
    - Moved FlagShip specific function from core to new hbfship lib.
    * Changed SECONDSCPU() to be just a wrapper over core HB_SECONDSCPU().
    ; INCOMPATIBLE: If you used SECONDSCPU() function, change it to
                    HB_SECONDSCPU(), or add hbfship to your lib list.
                    If you used STRPEEK() or STRPOKE() functions,
                    add hbfship to your lib list.

  * utils/hbmk2/examples/contribf.hbc
    + Added hbfship.
2010-02-20 11:57:17 +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
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 := 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