2011-03-05 15:41 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbexprb.c
+ enabled o:var += <cString> optimization when -ko switch is used
I added this optimization few years ago but I haven't enabled it
so far.
+ harbour/tests/speedstr.prg
+ added test code for <exp> += <cString> optimization
Try this code compiled with -kc switch (disabled += optimization)
without any -k? switches (default, += optimized for all expressions
except <obj>:<msg>) and finally with -ko switch (+= optimized for
all expressions)
(Warning for larger string non optimized code begins to be _very_
slow, i.e. for '#define N_LOOP 1000000' it needs fee minutes to
pass single test)
This commit is contained in:
@@ -16,6 +16,22 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2011-03-05 15:41 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/include/hbexprb.c
|
||||
+ enabled o:var += <cString> optimization when -ko switch is used
|
||||
I added this optimization few years ago but I haven't enabled it
|
||||
so far.
|
||||
|
||||
+ harbour/tests/speedstr.prg
|
||||
+ added test code for <exp> += <cString> optimization
|
||||
Try this code compiled with -kc switch (disabled += optimization)
|
||||
without any -k? switches (default, += optimized for all expressions
|
||||
except <obj>:<msg>) and finally with -ko switch (+= optimized for
|
||||
all expressions)
|
||||
(Warning for larger string non optimized code begins to be _very_
|
||||
slow, i.e. for '#define N_LOOP 1000000' it needs fee minutes to
|
||||
pass single test)
|
||||
|
||||
2011-03-04 17:50 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
|
||||
* contrib/hbxbp/xbpappevent.prg
|
||||
+ Added: XbpAppEventToQKeyEvent() and XbpAppEventModifier()
|
||||
|
||||
@@ -58,9 +58,7 @@
|
||||
#endif
|
||||
|
||||
#define HB_USE_ARRAYAT_REF
|
||||
/* Temporary disabled optimization with references to object variables
|
||||
until we will not have extended reference items in our HVM [druzus] */
|
||||
/* #define HB_USE_OBJMSG_REF */
|
||||
#define HB_USE_OBJMSG_REF
|
||||
|
||||
|
||||
/* Forward declarations
|
||||
@@ -4804,7 +4802,7 @@ static void hb_compExprPushOperEq( HB_EXPR_PTR pSelf, HB_BYTE bOpEq, HB_COMP_DEC
|
||||
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
|
||||
{
|
||||
#ifdef HB_USE_OBJMSG_REF
|
||||
if( bOpEq != bNewOp )
|
||||
if( HB_SUPPORT_EXTOPT && bOpEq != bNewOp )
|
||||
{
|
||||
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
|
||||
HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF );
|
||||
@@ -4953,7 +4951,7 @@ static void hb_compExprUseOperEq( HB_EXPR_PTR pSelf, HB_BYTE bOpEq, HB_COMP_DECL
|
||||
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
|
||||
{
|
||||
#ifdef HB_USE_OBJMSG_REF
|
||||
if( bOpEq != bNewOp )
|
||||
if( HB_SUPPORT_EXTOPT && bOpEq != bNewOp )
|
||||
{
|
||||
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
|
||||
HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF );
|
||||
@@ -5072,7 +5070,7 @@ static void hb_compExprPushPreOp( HB_EXPR_PTR pSelf, HB_BYTE bOper, HB_COMP_DECL
|
||||
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
|
||||
{
|
||||
#ifdef HB_USE_OBJMSG_REF
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
if( HB_SUPPORT_EXTOPT )
|
||||
{
|
||||
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
|
||||
HB_GEN_FUNC1( PCode1, HB_P_PUSHOVARREF );
|
||||
@@ -5174,7 +5172,7 @@ static void hb_compExprPushPostOp( HB_EXPR_PTR pSelf, HB_BYTE bOper, HB_COMP_DEC
|
||||
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
|
||||
{
|
||||
#ifdef HB_USE_OBJMSG_REF
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
if( HB_SUPPORT_EXTOPT )
|
||||
{
|
||||
/* push reference to current value */
|
||||
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
|
||||
@@ -5285,7 +5283,7 @@ static void hb_compExprUsePreOp( HB_EXPR_PTR pSelf, HB_BYTE bOper, HB_COMP_DECL
|
||||
if( pSelf->value.asOperator.pLeft->ExprType == HB_ET_SEND )
|
||||
{
|
||||
#ifdef HB_USE_OBJMSG_REF
|
||||
if( HB_SUPPORT_HARBOUR )
|
||||
if( HB_SUPPORT_EXTOPT )
|
||||
{
|
||||
/* push reference to current value */
|
||||
hb_compExprPushSendPop( pSelf->value.asOperator.pLeft, HB_COMP_PARAM );
|
||||
|
||||
77
harbour/tests/speedstr.prg
Normal file
77
harbour/tests/speedstr.prg
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* speed test program for string concatenation by += operator
|
||||
*
|
||||
* Copyright 2011 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#define N_LOOP 200000
|
||||
|
||||
#ifndef __XHARBOUR__
|
||||
#translate secondsCPU( => hb_secondsCPU(
|
||||
#endif
|
||||
#ifdef __XPP__
|
||||
#translate secondsCPU( => seconds(
|
||||
#endif
|
||||
#ifdef __HARBOUR__
|
||||
#include "hbclass.ch"
|
||||
#endif
|
||||
|
||||
proc main()
|
||||
memvar p
|
||||
local i, t
|
||||
local l, o
|
||||
static s, s2[1]
|
||||
private p
|
||||
p := s2[1] := s := l := ""
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
l += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "LOCAL +=", t, "sec."
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
s += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "STATIC +=", t, "sec."
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
s2[1] += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "ARRAY[] +=", t, "sec."
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
p += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "PRIVATE +=", t, "sec."
|
||||
p := ""; s := "p"
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
&s += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "MACRO +=", t, "sec."
|
||||
o := mycls():new(); o:v := ""
|
||||
t := secondsCPU()
|
||||
for i := 1 to N_LOOP
|
||||
o:v += chr( i )
|
||||
next
|
||||
t := secondsCPU() - t
|
||||
? "OBJECT:VAR +=", t, "sec."
|
||||
wait
|
||||
return
|
||||
|
||||
class mycls
|
||||
exported:
|
||||
var v
|
||||
endclass
|
||||
Reference in New Issue
Block a user