Sorry for the previous post, this is the correct test:

Harbour  looses 38.571 Bytes in 9.25 seconds
xHarbour looses 56.956 Bytes in 4.83 seconds

Why Harbour is more slow ?
Why xHarbour loose more memory ?

Why 2 compilers loose memory ?

Best regards,
Miguel Angel Marchuet


#include "hbmemory.ch"
#include "hbclass.ch"

#define MAXTEST 10000

PROCEDURE MAIN()
    LOCAL n, ao := {}, nMem, nTime

    REQUEST HB_GT_WIN

    nTime := Seconds()
    nMem := Memory( HB_MEM_USED )

    FOR n := 1 TO MAXTEST

       aAdd( ao, PROBLEM() )

       // Here harbour have a loose of performance. ????
       ao[n] := Nil

       hb_gcAll( .T. )
       ? 'Mem used -> ' + AllTrim( Str( Memory( HB_MEM_USED ) ) )

    NEXT

    ao := {}
    hb_gcAll( .T. )

    ? "We lost " + AllTrim( Str( Memory( HB_MEM_USED ) - nMem ) ) + " Bytes"
    ? "Elapsed time " + AllTrim( Str( Seconds() - nTime ) )

RETURN

FUNCTION PROBLEM()
    LOCAL cValue := {'   '}
    LOCAL oMem1 := Mem():New()
RETURN Ctl():New( oMem1, bSetGet( cValue, 1 ), 'XXXX' )

CLASS Mem
    DATA aValues INIT {}
    DATA oFriend
    METHOD New( oFriend ) CONSTRUCTOR
    METHOD AddItem( oItem ) INLINE AAdd( ::aValues, oItem )
ENDCLASS

METHOD New( oFriend ) CLASS Mem

    IF ! Empty( oFriend )
       ::oFriend := oFriend
       oFriend:AddItem( Self )
    ENDIF

RETURN Self

CLASS Ctl
    DATA oFriend
    DATA oGet
    METHOD New( oFriend, bSetGet, cPict ) CONSTRUCTOR
ENDCLASS

METHOD New( oFriend, bSetGet, cPict ) CLASS Ctl
    oFriend:AddItem( Self )
    ::oFriend := oFriend
    ::oGet    := GetNew( 20, 20, bSetGet,, cPict )
RETURN Self

FUNCTION bSetGet( uVar, nVal )
RETURN {|u| If( PCount() > 1, uVar[nVal] := u, uVar[nVal] ) }


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
xHarbour-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to