On Thu, 10 Nov 2011, Enrico Maria Giordano wrote:
> > > This is not a real world test, sorry.
> > Can you exaplain why?
> You don't need of my explanation. You know much better than me of what I'm 
> talking about.

For me it's perfect test which shows the performance of different
HVM operations so I'm very interesting why you do not find it as
good enough to compare HVM performance and you are expecting different
results in real life applications. You are presenting such opinion
in different public forums and I would like to know why and what is
wrong in this tests so I can improve it.

Anyhow maybe you will find this real life code as more interesting.
Long time ago one of my friends asked me about help in one mathematical
problem. He had to resolve this equation:

      TOTEK
    +    TO
    + TWOJA
   =========
     SZANSA

knowing that T, O, E, K, W, J, A, S, Z and N are different decimal
digits. (BTW in free translation above means: 'lottery is your chance'
I'm attaching PRG code which calculates it. It's example of dynamic
programing very often used to resolve real life problems in business
applications like 'the best (shortest) way for van', 'the most efficient
rules to invest money in production of different goods', etc. so without
any doubts it is a real speed example for anyone who has to create
expensive calculations at PRG level.
Below are results of this test I've just made in my system:

xHarbour -n -w -es2 -l -gc0
   real time: 23.07 sec.
    CPU time: 23.06 sec.

xHarbour -n -w -es2 -l -gc3
   real time: 14.69 sec.
    CPU time: 14.69 sec.

Harbour -n -w -es2 -l -kmo -gc0
   real time: 15.62 sec.
    CPU time: 15.60 sec.

Harbour -n -w -es2 -l -kmo -gc3
   real time: 10.79 sec.
    CPU time: 10.77 sec.

Please note that it's rather small problem and in real life we
have to calculates much bigger things.

best regards,
Przemek
#ifdef __XHARBOUR__
   #define hb_secondsCPU() secondsCPU()
#endif
#ifdef __CLIP__
   #define hb_secondsCPU() secondsCPU()
#endif
#ifdef FlagShip
   #define hb_secondsCPU() secondsCPU()
#endif
#ifndef hb_secondsCPU
   #ifndef __HARBOUR__
      #define hb_secondsCPU() seconds()
   #endif
#endif
static found:=0
static a:={1,2,3,4,5,6,7,8,9,0}
static l
proc main()
local sec, cpusec

? date(), time(), version(), os()

? "Startup loop to increase CPU clock..."
sec := seconds() + 3; while sec > seconds(); enddo

sec:=seconds()
cpusec:=hb_secondsCPU()

? "calculating results..."
l:=len(a)
count(0)

?
? "Solutions found: " + ltrim(str(found))
? "      real time: " + ltrim(str(seconds()-sec)) + " sec."
? "       CPU time: " + ltrim(str(hb_secondsCPU()-cpusec)) + " sec."
?
return

static proc count(n)
local i, x
if n==l
   check()
else
   ++n
   for i:=n to l
      x:=a[n]
      a[n]:=a[i]
      a[i]:=x
      count(n)
      a[i]:=a[n]
      a[n]:=x
   next
endif
return

static proc check()
if                     ( ( ( ( a[1] )*10 + a[2] )*10 + a[1] )*10 + a[3] )*10 + 
a[4] ;
                  +                                              ( a[1] )*10 + 
a[2] ;
                  +    ( ( ( ( a[1] )*10 + a[5] )*10 + a[2] )*10 + a[6] )*10 + 
a[7] ;
        ==   ( ( ( ( a[8]*10 + a[9] )*10 + a[7] )*10 + a[10])*10 + a[8] )*10 + 
a[7]
   ? "solution:", ++found
   ? " " +         str(a[1],1) + str(a[2],1) + str(a[1],1) + str(a[3],1) + 
str(a[4],1)
   ? "   +" +                                                str(a[1],1) + 
str(a[2],1)
   ? "+" +         str(a[1],1) + str(a[5],1) + str(a[2],1) + str(a[6],1) + 
str(a[7],1)
   ? "======"
   ? str(a[8],1) + str(a[9],1) + str(a[7],1) + str(a[10],1)+ str(a[8],1) + 
str(a[7],1)
   ?
endif
return
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to