For Programmers: Free Programming Magazines  


Home > Archive > Clipper > October 2005 > Clipper speed in .net









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Clipper speed in .net
Massimo Belgrano

2005-10-10, 3:55 am

what is the real speed overhead of The full implementation of Clipper
behavior in .NET - . I'm really interesting
in results.
I would like to see the results from speedtst.prg (from xharbour
distribution) compiled by CULE.
Can someone with Windows machine and .NET CULE make such tests and send the
results with information about used
machine or email me the compiled exe,and modified source.



/*
* $Id: speedtst.prg,v 1.7 2005/05/10 20:56:13 druzus Exp $
*/

#define ARR_LEN 16
#define N_LOOPS 1000000

//#define NO_DBF_TEST
#define NO_KEYBOARD_TEST
#define NO_ASSOC_TEST

#define REAL_TIME

#ifdef __CLIP__
#define ASSOC_ARRAY map()
#undef REAL_TIME
#endif
#ifdef FlagShip
#undef REAL_TIME
#xtranslate seconds() => fs_seconds()
#endif
#ifdef __XHARBOUR__
#define ASSOC_ARRAY Hash()
#undef REAL_TIME
#endif
#ifdef __HARBOUR__
#undef REAL_TIME
#endif

#ifdef REAL_TIME
#xtranslate secondscpu([<x>]) => seconds()
#endif
#ifndef EOL
#define EOL chr(10)
#endif
#command ? => outstd(EOL)
#command ? <xx,...> => outstd(<xx>, EOL)

#ifdef NO_ASSOC_TEST
#undef ASSOC_ARRAY
#endif

function main()
#ifndef NO_DBF_TEST
field F_C, F_N, F_D
#endif
memvar M_C, M_N, M_D
local L_C, L_N, L_D
local i, j, t, c, c2, n, d, o, bc, tn, total, totalr, aa,;
a[ARR_LEN], a2[ARR_LEN], a3[ARR_LEN], aDb, cFi
#ifdef ASSOC_ARRAY
local aAssoc := ASSOC_ARRAY
#endif
private M_C := dtos(date()),;
M_N := 112345.67,;
M_D := date()

#ifndef __CLIP__
//#ifdef __XHARBOUR__
// setcancel(.f.)
// altd(0)
//#endif
#endif
#ifdef __CLIP__
SET MACRO_IN_STRING OFF
//CLEAR SCREEN
#endif
#ifdef FlagShip
FS_SET( "zerobyte", .t. )
FS_SET( "devel", .f. )
// FS_SET( "break", 0 )
// FS_SET( "debug", 0 )
#endif

for i:=1 to len(a)
a[i]:=i
a2[i]:=dtos(date())+chr(i%64+32)+chr(i%6
4+64)+str(i,10)
a3[i]:=stuff(dtos(date()),7,0,".")
next

? ""
? VERSION()+", "+OS()
? "ARR_LEN =", ARR_LEN
? "N_LOOPS =", N_LOOPS

t:=secondscpu()
for i:=1 to N_LOOPS
next
tn:=secondscpu()-t
? "empty loops overhead =", tn
#ifdef REAL_TIME
? "real time -> seconds()"
#else
? "CPU usage -> secondsCPU()"
#endif
? ""

aDb:={ {"F_C", "C", 10, 0},;
{"F_N", "N", 10, 2},;
{"F_D", "D", 8, 0} }
cFi:="tst_tmp.dbf"
if file(cFi)
ferase(cFi)
endif

#ifndef NO_DBF_TEST
dbcreate(cFi, aDb)
select(1)
use &cFi shared
dbappend()
replace F_C with dtos(date())
replace F_N with 112345.67
replace F_D with date()
dbcommit()
dbunlock()

cFi:="tst_tmp2.dbf"
if file(cFi)
ferase(cFi)
endif
dbcreate(cFi, aDb)
select(2)
use &cFi exclusive
dbappend()
replace F_C with dtos(date())
replace F_N with 112345.67
replace F_D with date()
dbcommit()
dbunlock()
#endif

L_C := dtos(date())
L_N := 112345.67
L_D := date()


total:=secondscpu()
totalr:=seconds()
t:=secondscpu()
for i:=1 to N_LOOPS
c:=L_C
next
dsp_time( "c:=L_C -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
n:=L_N
next
dsp_time( "n:=L_N -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
d:=L_D
next
dsp_time( "d:=L_D -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
c:=M_C
next
dsp_time( "c:=M_C -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
n:=M_N
next
dsp_time( "n:=M_N -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
d:=M_D
next
dsp_time( "d:=M_D -> ", t, tn)

#ifndef NO_DBF_TEST
select(1)
t:=secondscpu()
for i:=1 to N_LOOPS
c:=F_C
next
dsp_time( "(sh) c:=F_C -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
n:=F_N
next
dsp_time( "(sh) n:=F_N -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
d:=F_D
next
dsp_time( "(sh) d:=F_D -> ", t, tn)

select(2)
t:=secondscpu()
for i:=1 to N_LOOPS
c:=F_C
next
dsp_time( "(ex) c:=F_C -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
n:=F_N
next
dsp_time( "(ex) n:=F_N -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
d:=F_D
next
dsp_time( "(ex) d:=F_D -> ", t, tn)
#endif

o:=errorNew()
t:=secondscpu()
for i:=1 to N_LOOPS
n:=o:GenCode
next
dsp_time( "n:=o:GenCode -> ", t, tn)

#ifdef ASSOC_ARRAY
t:=secondscpu()
for i:=1 to N_LOOPS
aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%100))
]:=i
next
dsp_time( " aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%100)]
:=i -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
c:=aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%10
0))]
next
dsp_time( " c:=aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%10
0)] -> ", t, tn)
#endif

#ifndef NO_KEYBOARD_TEST
t:=secondscpu()
for i:=1 to N_LOOPS
inkey()
next
dsp_time( "inkey() -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
nextkey()
next
dsp_time( "nextkey() -> ", t, tn)
#endif

t:=secondscpu()
for i:=1 to N_LOOPS
round(i/1000,2)
next
dsp_time( "round(i/1000,2) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
str(i/1000)
next
dsp_time( "str(i/1000) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
val(a3[i%ARR_LEN+1])
next
dsp_time( "val(a3[i%ARR_LEN+1]) -> ", t, tn)

t:=secondscpu()
j:=date()
for i:=1 to N_LOOPS
dtos(j+i%10000-5000)
next
dsp_time( "dtos(j+i%10000-5000) -> ", t, tn)

bc:={||i%ARR_LEN}
t:=secondscpu()
for i:=1 to N_LOOPS
eval(bc)
next
dsp_time( "eval({||i%ARR_LEN}) -> ", t, tn)

bc:={|x|x%ARR_LEN}
t:=secondscpu()
for i:=1 to N_LOOPS
eval(bc,i)
next
dsp_time( "eval({|x|x%ARR_LEN}) -> ", t, tn)

bc:={|x|f1(x)}
t:=secondscpu()
for i:=1 to N_LOOPS
eval(bc,i)
next
dsp_time( "eval({|x|f1(x)}) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
n:=&("f1("+str(i)+")")
next
dsp_time( "&('f1('+str(i)+')') -> ", t, tn)

bc:=&("{|x|f1(x)}")
t:=secondscpu()
for i:=1 to N_LOOPS
eval(bc,i)
next
dsp_time( "eval([&('{|x|f1(x)}')]) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
j:=valtype(a)+valtype(i)
next
dsp_time( "j := valtype(a)+valtype(i) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
j := str(i%100,2) $ a2[i%ARR_LEN+1]
next
dsp_time( "j := str(i%100,2) $ a2[i%ARR_LEN+1] -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
j := val(a2[i%ARR_LEN+1])
next
dsp_time( "j := val(a2[i%ARR_LEN+1]) -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
j := a2[i%ARR_LEN+1] == c
next
dsp_time( "j := a2[i%ARR_LEN+1] == s -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
j := a2[i%ARR_LEN+1] = c
next
dsp_time( "j := a2[i%ARR_LEN+1] = s -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
j := a2[i%ARR_LEN+1] >= c
next
dsp_time( "j := a2[i%ARR_LEN+1] >= s -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
j := a2[i%ARR_LEN+1] < c
next
dsp_time( "j := a2[i%ARR_LEN+1] < s -> ", t, tn)

aa:={}
t:=secondscpu()
for i:=1 to N_LOOPS
if i%1000 == 0
aa:={}
endif
aadd(aa,{i,j,c,a,a2,t,bc})
next
dsp_time( "aadd(aa,{i,j,s,a,a2,t,bc}) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f0()
next
dsp_time( "f0() -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f1(i)
next
dsp_time( "f1(i) -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
f2(c)
next
dsp_time( "f2(c["+ltrim(str(len(c)))+"]) -> ", t, tn)

c:=replicate(c,5000)
t:=secondscpu()
for i:=1 to N_LOOPS
f2(c)
next
dsp_time( "f2(c["+ltrim(str(len(c)))+"]) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f2(@c)
next
dsp_time( "f2(@c["+ltrim(str(len(c)))+"]) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f2(c)
c2:=c
next
dsp_time( "f2(c["+ltrim(str(len(c)))+"]); c2:=c -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f2(@c)
c2:=c
next
dsp_time( "f2(@c["+ltrim(str(len(c)))+"]); c2:=c -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
f3(a,a2,c,i,j,t,bc)
next
dsp_time( "f3(a,a2,c,i,j,t,bc) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
f2(a2)
next
dsp_time( "f2(a2) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
c:=f4()
next
dsp_time( "s:=f4() -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
ascan(a,i%ARR_LEN)
next
dsp_time( "ascan(a,i%ARR_LEN) -> ", t, tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to N_LOOPS
ascan(a2,c+chr(i%64+64))
next
dsp_time( "ascan(a2,c+chr(i%64+64)) -> ", t, tn)

t:=secondscpu()
for i:=1 to N_LOOPS
ascan(a,{|x|x==i%ARR_LEN})
next
dsp_time( "ascan(a,{|x|x==i%ARR_LEN}) -> ", t, tn)

? replicate("=",60)
dsp_time( "total application time:", total, 0)
? padr( "total real time:",50)+str(seconds()-totalr,8,2)
?
return nil

function dsp_time(s,t,tn)
? padr(s,50)+str(max(secondscpu()-t-tn,0),8,2)
return nil

function f0(x)
return nil

function f1(x)
return x+1

function f2(s)
return nil

function f3(a,b,c,d,e,f,g,h,i)
return nil

function f4()
return space(50000)

#ifdef FlagShip
function fs_seconds()
LOCAL_DOUBLE nret := 0
#Cinline
{
#include <sys/time.h>
struct timeval tv;
struct timezone tz;
if( !gettimeofday(&tv, NULL) )
nret = (double) tv.tv_sec + (double) (tv.tv_usec) / 1000000;
/*
nret = (double) (tv.tv_sec - tz.tz_minuteswest * 60 ) % 86400 +
(double) tv.tv_usec / 1000000;
*/
}
#endCinline
return ( nret )

#ifndef FlagShip5
FUNCTION cursesinit()
CALL fgsIoctl2
#Cinline
{
#include <fcntl.h>
int arg;
if ((arg = fcntl(0, F_GETFL, 0)) != -1)
fcntl(0, F_SETFL, arg | O_NONBLOCK);
}
#endCinline
return nil
#endif
#endif







frank van nuffel

2005-10-10, 7:55 am

Massimo, the provided source is incompatible with CULE

frank

"Massimo Belgrano" schreef in bericht news:did8dc$nku$1@area.cu.mi.it...

> what is the real speed overhead of The full implementation of Clipper
> behavior in .NET - . I'm really interesting
> in results.
> I would like to see the results from speedtst.prg (from xharbour
> distribution) compiled by CULE.
> Can someone with Windows machine and .NET CULE make such tests and send
> the results with information about used
> machine or email me the compiled exe,and modified source.
>
>
>
> /*
> * $Id: speedtst.prg,v 1.7 2005/05/10 20:56:13 druzus Exp $
> */
>
> #define ARR_LEN 16
> #define N_LOOPS 1000000
>
> //#define NO_DBF_TEST
> #define NO_KEYBOARD_TEST
> #define NO_ASSOC_TEST
>
> #define REAL_TIME
>
> #ifdef __CLIP__
> #define ASSOC_ARRAY map()
> #undef REAL_TIME
> #endif
> #ifdef FlagShip
> #undef REAL_TIME
> #xtranslate seconds() => fs_seconds()
> #endif
> #ifdef __XHARBOUR__
> #define ASSOC_ARRAY Hash()
> #undef REAL_TIME
> #endif
> #ifdef __HARBOUR__
> #undef REAL_TIME
> #endif
>
> #ifdef REAL_TIME
> #xtranslate secondscpu([<x>]) => seconds()
> #endif
> #ifndef EOL
> #define EOL chr(10)
> #endif
> #command ? => outstd(EOL)
> #command ? <xx,...> => outstd(<xx>, EOL)
>
> #ifdef NO_ASSOC_TEST
> #undef ASSOC_ARRAY
> #endif
>
> function main()
> #ifndef NO_DBF_TEST
> field F_C, F_N, F_D
> #endif
> memvar M_C, M_N, M_D
> local L_C, L_N, L_D
> local i, j, t, c, c2, n, d, o, bc, tn, total, totalr, aa,;
> a[ARR_LEN], a2[ARR_LEN], a3[ARR_LEN], aDb, cFi
> #ifdef ASSOC_ARRAY
> local aAssoc := ASSOC_ARRAY
> #endif
> private M_C := dtos(date()),;
> M_N := 112345.67,;
> M_D := date()
>
> #ifndef __CLIP__
> //#ifdef __XHARBOUR__
> // setcancel(.f.)
> // altd(0)
> //#endif
> #endif
> #ifdef __CLIP__
> SET MACRO_IN_STRING OFF
> //CLEAR SCREEN
> #endif
> #ifdef FlagShip
> FS_SET( "zerobyte", .t. )
> FS_SET( "devel", .f. )
> // FS_SET( "break", 0 )
> // FS_SET( "debug", 0 )
> #endif
>
> for i:=1 to len(a)
> a[i]:=i
> a2[i]:=dtos(date())+chr(i%64+32)+chr(i%6
4+64)+str(i,10)
> a3[i]:=stuff(dtos(date()),7,0,".")
> next
>
> ? ""
> ? VERSION()+", "+OS()
> ? "ARR_LEN =", ARR_LEN
> ? "N_LOOPS =", N_LOOPS
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> next
> tn:=secondscpu()-t
> ? "empty loops overhead =", tn
> #ifdef REAL_TIME
> ? "real time -> seconds()"
> #else
> ? "CPU usage -> secondsCPU()"
> #endif
> ? ""
>
> aDb:={ {"F_C", "C", 10, 0},;
> {"F_N", "N", 10, 2},;
> {"F_D", "D", 8, 0} }
> cFi:="tst_tmp.dbf"
> if file(cFi)
> ferase(cFi)
> endif
>
> #ifndef NO_DBF_TEST
> dbcreate(cFi, aDb)
> select(1)
> use &cFi shared
> dbappend()
> replace F_C with dtos(date())
> replace F_N with 112345.67
> replace F_D with date()
> dbcommit()
> dbunlock()
>
> cFi:="tst_tmp2.dbf"
> if file(cFi)
> ferase(cFi)
> endif
> dbcreate(cFi, aDb)
> select(2)
> use &cFi exclusive
> dbappend()
> replace F_C with dtos(date())
> replace F_N with 112345.67
> replace F_D with date()
> dbcommit()
> dbunlock()
> #endif
>
> L_C := dtos(date())
> L_N := 112345.67
> L_D := date()
>
>
> total:=secondscpu()
> totalr:=seconds()
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=L_C
> next
> dsp_time( "c:=L_C -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=L_N
> next
> dsp_time( "n:=L_N -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> d:=L_D
> next
> dsp_time( "d:=L_D -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=M_C
> next
> dsp_time( "c:=M_C -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=M_N
> next
> dsp_time( "n:=M_N -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> d:=M_D
> next
> dsp_time( "d:=M_D -> ", t, tn)
>
> #ifndef NO_DBF_TEST
> select(1)
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=F_C
> next
> dsp_time( "(sh) c:=F_C -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=F_N
> next
> dsp_time( "(sh) n:=F_N -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> d:=F_D
> next
> dsp_time( "(sh) d:=F_D -> ", t, tn)
>
> select(2)
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=F_C
> next
> dsp_time( "(ex) c:=F_C -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=F_N
> next
> dsp_time( "(ex) n:=F_N -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> d:=F_D
> next
> dsp_time( "(ex) d:=F_D -> ", t, tn)
> #endif
>
> o:=errorNew()
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=o:GenCode
> next
> dsp_time( "n:=o:GenCode -> ", t, tn)
>
> #ifdef ASSOC_ARRAY
> t:=secondscpu()
> for i:=1 to N_LOOPS
> aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%100))
]:=i
> next
> dsp_time( " aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%100)]
:=i -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%10
0))]
> next
> dsp_time( " c:=aAssoc[a2[i%ARR_LEN+1]+ltrim(str(i%10
0)] -> ", t, tn)
> #endif
>
> #ifndef NO_KEYBOARD_TEST
> t:=secondscpu()
> for i:=1 to N_LOOPS
> inkey()
> next
> dsp_time( "inkey() -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> nextkey()
> next
> dsp_time( "nextkey() -> ", t, tn)
> #endif
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> round(i/1000,2)
> next
> dsp_time( "round(i/1000,2) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> str(i/1000)
> next
> dsp_time( "str(i/1000) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> val(a3[i%ARR_LEN+1])
> next
> dsp_time( "val(a3[i%ARR_LEN+1]) -> ", t, tn)
>
> t:=secondscpu()
> j:=date()
> for i:=1 to N_LOOPS
> dtos(j+i%10000-5000)
> next
> dsp_time( "dtos(j+i%10000-5000) -> ", t, tn)
>
> bc:={||i%ARR_LEN}
> t:=secondscpu()
> for i:=1 to N_LOOPS
> eval(bc)
> next
> dsp_time( "eval({||i%ARR_LEN}) -> ", t, tn)
>
> bc:={|x|x%ARR_LEN}
> t:=secondscpu()
> for i:=1 to N_LOOPS
> eval(bc,i)
> next
> dsp_time( "eval({|x|x%ARR_LEN}) -> ", t, tn)
>
> bc:={|x|f1(x)}
> t:=secondscpu()
> for i:=1 to N_LOOPS
> eval(bc,i)
> next
> dsp_time( "eval({|x|f1(x)}) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> n:=&("f1("+str(i)+")")
> next
> dsp_time( "&('f1('+str(i)+')') -> ", t, tn)
>
> bc:=&("{|x|f1(x)}")
> t:=secondscpu()
> for i:=1 to N_LOOPS
> eval(bc,i)
> next
> dsp_time( "eval([&('{|x|f1(x)}')]) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j:=valtype(a)+valtype(i)
> next
> dsp_time( "j := valtype(a)+valtype(i) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := str(i%100,2) $ a2[i%ARR_LEN+1]
> next
> dsp_time( "j := str(i%100,2) $ a2[i%ARR_LEN+1] -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := val(a2[i%ARR_LEN+1])
> next
> dsp_time( "j := val(a2[i%ARR_LEN+1]) -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := a2[i%ARR_LEN+1] == c
> next
> dsp_time( "j := a2[i%ARR_LEN+1] == s -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := a2[i%ARR_LEN+1] = c
> next
> dsp_time( "j := a2[i%ARR_LEN+1] = s -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := a2[i%ARR_LEN+1] >= c
> next
> dsp_time( "j := a2[i%ARR_LEN+1] >= s -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> j := a2[i%ARR_LEN+1] < c
> next
> dsp_time( "j := a2[i%ARR_LEN+1] < s -> ", t, tn)
>
> aa:={}
> t:=secondscpu()
> for i:=1 to N_LOOPS
> if i%1000 == 0
> aa:={}
> endif
> aadd(aa,{i,j,c,a,a2,t,bc})
> next
> dsp_time( "aadd(aa,{i,j,s,a,a2,t,bc}) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f0()
> next
> dsp_time( "f0() -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f1(i)
> next
> dsp_time( "f1(i) -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(c)
> next
> dsp_time( "f2(c["+ltrim(str(len(c)))+"]) -> ", t, tn)
>
> c:=replicate(c,5000)
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(c)
> next
> dsp_time( "f2(c["+ltrim(str(len(c)))+"]) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(@c)
> next
> dsp_time( "f2(@c["+ltrim(str(len(c)))+"]) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(c)
> c2:=c
> next
> dsp_time( "f2(c["+ltrim(str(len(c)))+"]); c2:=c -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(@c)
> c2:=c
> next
> dsp_time( "f2(@c["+ltrim(str(len(c)))+"]); c2:=c -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f3(a,a2,c,i,j,t,bc)
> next
> dsp_time( "f3(a,a2,c,i,j,t,bc) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> f2(a2)
> next
> dsp_time( "f2(a2) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> c:=f4()
> next
> dsp_time( "s:=f4() -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> ascan(a,i%ARR_LEN)
> next
> dsp_time( "ascan(a,i%ARR_LEN) -> ", t, tn)
>
> c:=dtos(date())
> t:=secondscpu()
> for i:=1 to N_LOOPS
> ascan(a2,c+chr(i%64+64))
> next
> dsp_time( "ascan(a2,c+chr(i%64+64)) -> ", t, tn)
>
> t:=secondscpu()
> for i:=1 to N_LOOPS
> ascan(a,{|x|x==i%ARR_LEN})
> next
> dsp_time( "ascan(a,{|x|x==i%ARR_LEN}) -> ", t, tn)
>
> ? replicate("=",60)
> dsp_time( "total application time:", total, 0)
> ? padr( "total real time:",50)+str(seconds()-totalr,8,2)
> ?
> return nil
>
> function dsp_time(s,t,tn)
> ? padr(s,50)+str(max(secondscpu()-t-tn,0),8,2)
> return nil
>
> function f0(x)
> return nil
>
> function f1(x)
> return x+1
>
> function f2(s)
> return nil
>
> function f3(a,b,c,d,e,f,g,h,i)
> return nil
>
> function f4()
> return space(50000)
>
> #ifdef FlagShip
> function fs_seconds()
> LOCAL_DOUBLE nret := 0
> #Cinline
> {
> #include <sys/time.h>
> struct timeval tv;
> struct timezone tz;
> if( !gettimeofday(&tv, NULL) )
> nret = (double) tv.tv_sec + (double) (tv.tv_usec) / 1000000;
> /*
> nret = (double) (tv.tv_sec - tz.tz_minuteswest * 60 ) % 86400 +
> (double) tv.tv_usec / 1000000;
> */
> }
> #endCinline
> return ( nret )
>
> #ifndef FlagShip5
> FUNCTION cursesinit()
> CALL fgsIoctl2
> #Cinline
> {
> #include <fcntl.h>
> int arg;
> if ((arg = fcntl(0, F_GETFL, 0)) != -1)
> fcntl(0, F_SETFL, arg | O_NONBLOCK);
> }
> #endCinline
> return nil
> #endif
> #endif
>
>
>
>
>
>
>



Przemyslaw Czerpak

2005-10-10, 7:55 am

On Mon, 10 Oct 2005 11:03:37 +0200,
frank van nuffel <clipper-y2d@versateladsl.be> wrote:
> Massimo, the provided source is incompatible with CULE


What is the source of problem?
Doesn't CULE compile pure Clipper code?

best regards,
Przemek
frank van nuffel

2005-10-10, 6:55 pm

Hello Przemyslaw,

"Przemyslaw Czerpak" in bericht
news:slrndkkohf.4i5.druzus@localhost.localdomain...

> What is the source of problem?
> Doesn't CULE compile pure Clipper code?


No, apparently not; some of these might get corrected in future versions
but as of today the CULE compiler flags errors on next occurences:

1) no support for #[x]command & #[x]translate
2) no support for memvar & field & private declarations
3) no support for local a[100] & date()
4) no support for = comparison operator (line 337)
5) no support for &(...)

just to name a few

frank


Massimo Belgrano

2005-10-10, 6:55 pm

This is the harbour ppo whith same modification
Seem that cule haven't Preprocessor as good as xharbour

function main()
aDbf := {}
AADD( aDbf, { "F_C", "C", 10, 0 } )
AADD( aDbf, { "F_C", "N", 12, 4 } )
AADD( aDbf, { "F_D", "D", 8, 0 } )
dbCreate("dbtest",aDbf)
USE dbtest // 'field F_C,F_N,F_D

PRIVATE M_C,M_N,M_D // 'memvar M_C,M_N,M_D
PRIVATE L_C,L_N,L_D // local L_C,L_N,L_D
PRIVATE i,j,t,c,c2,n,d,o,bc,tn,total,totalr,aa,a
[16],a2[16],a3[16],aDb,cFi
// local i,j,t,c,c2,n,d,o,bc,tn,total,totalr,aa,a
[16],a2[16],a3[16],aDb,cFi
private M_C := dtos(date()),M_N := 112345.67,M_D := date()
for i:=1 to len(a)
a[i]:=i
a2[i]:=dtos(date())+chr(i%64+32)+chr(i%6
4+64)+str(i,10)
a3[i]:=stuff(dtos(date()),7,0,".")
next

outstd("",chr(10))
outstd(VERSION()+", "+OS(),chr(10))
outstd("ARR_LEN =",16,chr(10))
outstd("N_LOOPS =",1000000,chr(10))

t:=secondscpu()
for i:=1 to 1000000
next
tn:=secondscpu()-t
outstd("empty loops overhead =",tn,chr(10))
outstd("CPU usage -> secondsCPU()",chr(10))
outstd("",chr(10))
aDb:={ {"F_C","C",10,0},{"F_N","N",10,2},{"F_D","D",8,0} }
cFi:="tst_tmp.dbf"
if file(cFi)
ferase(cFi)
endif


dbcreate(cFi,aDb)
dbSelectArea((1) )
dbUseArea(.F.,,cFi,,IIF(.T. .or. .F.,!.F.,NIL),.F.,,)
dbappend()
_FIELD->F_C := dtos(date())
_FIELD->F_N := 112345.67
_FIELD->F_D := date()
dbcommit()
dbunlock()

cFi:="tst_tmp2.dbf"
if file(cFi)
ferase(cFi)
endif
dbcreate(cFi,aDb)
dbSelectArea((2) )
dbUseArea(.F.,,cFi,,IIF(.F. .or. .T.,!.T.,NIL),.F.,,)
dbappend()
_FIELD->F_C := dtos(date())
_FIELD->F_N := 112345.67
_FIELD->F_D := date()
dbcommit()
dbunlock()


L_C := dtos(date())
L_N := 112345.67
L_D := date()


total:=secondscpu()
totalr:=seconds()
t:=secondscpu()
for i:=1 to 1000000
c:=L_C
next
dsp_time("c:=L_C -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
n:=L_N
next
dsp_time("n:=L_N -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
d:=L_D
next
dsp_time("d:=L_D -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
c:=M_C
next
dsp_time("c:=M_C -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
n:=M_N
next
dsp_time("n:=M_N -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
d:=M_D
next
dsp_time("d:=M_D -> ",t,tn)


dbSelectArea((1) )
t:=secondscpu()
for i:=1 to 1000000
c:=F_C
next
dsp_time("(sh) c:=F_C -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
n:=F_N
next
dsp_time("(sh) n:=F_N -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
d:=F_D
next
dsp_time("(sh) d:=F_D -> ",t,tn)

dbSelectArea((2) )
t:=secondscpu()
for i:=1 to 1000000
c:=F_C
next
dsp_time("(ex) c:=F_C -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
n:=F_N
next
dsp_time("(ex) n:=F_N -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
d:=F_D
next
dsp_time("(ex) d:=F_D -> ",t,tn)


o:=errorNew()
t:=secondscpu()
for i:=1 to 1000000
n:=o:GenCode
next
dsp_time("n:=o:GenCode -> ",t,tn)





























t:=secondscpu()
for i:=1 to 1000000
round(i/1000,2)
next
dsp_time("round(i/1000,2) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
str(i/1000)
next
dsp_time("str(i/1000) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
val(a3[i%16+1])
next
dsp_time("val(a3[i%ARR_LEN+1]) -> ",t,tn)

t:=secondscpu()
j:=date()
for i:=1 to 1000000
dtos(j+i%10000-5000)
next
dsp_time("dtos(j+i%10000-5000) -> ",t,tn)

bc:={||i%16}
t:=secondscpu()
for i:=1 to 1000000
eval(bc)
next
dsp_time("eval({||i%ARR_LEN}) -> ",t,tn)

bc:={|x|x%16}
t:=secondscpu()
for i:=1 to 1000000
eval(bc,i)
next
dsp_time("eval({|x|x%ARR_LEN}) -> ",t,tn)

bc:={|x|f1(x)}
t:=secondscpu()
for i:=1 to 1000000
eval(bc,i)
next
dsp_time("eval({|x|f1(x)}) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
n:=&("f1("+str(i)+")")
next
dsp_time("&('f1('+str(i)+')') -> ",t,tn)

bc:=&("{|x|f1(x)}")
t:=secondscpu()
for i:=1 to 1000000
eval(bc,i)
next
dsp_time("eval([&('{|x|f1(x)}')]) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
j:=valtype(a)+valtype(i)
next
dsp_time("j := valtype(a)+valtype(i) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
j := str(i%100,2) $ a2[i%16+1]
next
dsp_time("j := str(i%100,2) $ a2[i%ARR_LEN+1] -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
j := val(a2[i%16+1])
next
dsp_time("j := val(a2[i%ARR_LEN+1]) -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
j := a2[i%16+1] == c
next
dsp_time("j := a2[i%ARR_LEN+1] == s -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
j := a2[i%16+1] = c
next
dsp_time("j := a2[i%ARR_LEN+1] = s -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
j := a2[i%16+1] >= c
next
dsp_time("j := a2[i%ARR_LEN+1] >= s -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
j := a2[i%16+1] < c
next
dsp_time("j := a2[i%ARR_LEN+1] < s -> ",t,tn)

aa:={}
t:=secondscpu()
for i:=1 to 1000000
if i%1000 == 0
aa:={}
endif
aadd(aa,{i,j,c,a,a2,t,bc})
next
dsp_time("aadd(aa,{i,j,s,a,a2,t,bc}) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f0()
next
dsp_time("f0() -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f1(i)
next
dsp_time("f1(i) -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
f2(c)
next
dsp_time("f2(c["+ltrim(str(len(c)))+"]) -> ",t,tn)

c:=replicate(c,5000)
t:=secondscpu()
for i:=1 to 1000000
f2(c)
next
dsp_time("f2(c["+ltrim(str(len(c)))+"]) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f2(@c)
next
dsp_time("f2(@c["+ltrim(str(len(c)))+"]) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f2(c)
c2:=c
next
dsp_time("f2(c["+ltrim(str(len(c)))+"]); c2:=c -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f2(@c)
c2:=c
next
dsp_time("f2(@c["+ltrim(str(len(c)))+"]); c2:=c -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
f3(a,a2,c,i,j,t,bc)
next
dsp_time("f3(a,a2,c,i,j,t,bc) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
f2(a2)
next
dsp_time("f2(a2) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
c:=f4()
next
dsp_time("s:=f4() -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
ascan(a,i%16)
next
dsp_time("ascan(a,i%ARR_LEN) -> ",t,tn)

c:=dtos(date())
t:=secondscpu()
for i:=1 to 1000000
ascan(a2,c+chr(i%64+64))
next
dsp_time("ascan(a2,c+chr(i%64+64)) -> ",t,tn)

t:=secondscpu()
for i:=1 to 1000000
ascan(a,{|x|x==i%16})
next
dsp_time("ascan(a,{|x|x==i%ARR_LEN}) -> ",t,tn)

outstd(replicate("=",60),chr(10))
dsp_time("total application time:",total,0)
outstd(padr("total real time:",50)+str(seconds()-totalr,8,2),chr(10))
outstd(chr(10))
return nil

function dsp_time(s,t,tn)
outstd(padr(s,50)+str(max(secondscpu()-t-tn,0),8,2),chr(10))
return nil

function f0(x)
return nil

function f1(x)
return x+1

function f2(s)
return nil

function f3(a,b,c,d,e,f,g,h,i)
return nil

function f4()
return space(50000)


"frank van nuffel" <clipper-y2d@versateladsl.be> ha scritto nel messaggio
news:7d253$434a7ef5$52ae18b8$20845@news.versatel.nl...
> Hello Przemyslaw,
>
> "Przemyslaw Czerpak" in bericht
> news:slrndkkohf.4i5.druzus@localhost.localdomain...
>
>
> No, apparently not; some of these might get corrected in future versions
> but as of today the CULE compiler flags errors on next occurences:
>
> 1) no support for #[x]command & #[x]translate
> 2) no support for memvar & field & private declarations
> 3) no support for local a[100] & date()
> 4) no support for = comparison operator (line 337)
> 5) no support for &(...)
>
> just to name a few
>
> frank
>



frank van nuffel

2005-10-10, 6:55 pm

Massimo,

"Massimo Belgrano" in bericht news:diea5d$jgd$1@area.cu.mi.it...

> This is the harbour ppo whith same modification
> Seem that cule haven't Preprocessor as good as xharbour


you can try for yourself with CULE's Learning Edition; it's
a free download and it will bring up any errors i reported
so far; even when commenting portions out of the testcase
the CULE compiler is ultimately crashing on sth that is more
difficult to sort out

frank

ps: use CULE's /CLIPPER switch
ie: CULE.NET.EXE /F:speedtst.prg /CLIPPER


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com