Source language: Translate to:

Speedtest

Questions and information about using VBScript and JavaScript in NeoBook functions

Moderator: Neosoft Support

Speedtest

Postby reinier maliepaard » Sun Jan 18, 2009 4:02 am

I'm excited about Neobook 5.6.2 and VBScript. Recursive functions/nested loops were in Neobook always slow and CPU-consuming. The best alternative in terms of speed was the LUA-plugin, that is however no longer maintained. With VBScript you can make very fast applications with efficient use of CPU-resources. For demonstration purposes I made an application with a very inefficient and -in a way- silly Factorial-task and with a Replace task with necessary arrays and nested loops. To experiment with this application, implement the following VBScriptfunctions, save the NeobookPUBcode to test.pub and run the program. Thanks Neobook, for the VBScript-implementation!

---------------------------------------------------------------
Function 1: Factorial2

dim NNN, Factorial, FactTemp
NNN = publication.nbGetVar( "[selectN]" )

For i = 1 to NNN

Factorial = 1
If NNN > 1 Then
For FactTemp = 2 to NNN
Factorial = FactTemp * Factorial
Next
End If

Next

publication.nbSetVar "[Factorial2]", " " & Factorial & " "

---------------------------------------------------------------
Function 2: ReplaceVBScript

Dim myString
myString = publication.nbGetVar( "[myString]" )
Dim tt
tt = Array("x","A","B","C","D","E","F","G","a","b","c","d","e","f","g","Z","z","A,","B,","C,","D,","E,","F,","G,","A,,","B,,","C,,","D,,","E,,","F,,","G,,","a'","b'","c'","d'","e'","f'","g'")

Dim input, medio, output
input = Array("8..","4..","2..","1..","32.","16.","8.","4.","2.","1.","64","32","16","8","4","2","1111","11","1")
medio = Array("xnlap","xtyec","xswlo","xkuey","kiuw","miem","wroa","prle","jleh","wroe","chie","hluc","xlap","nlup","tiec","swlu","xxxnluup","xnluup","koey")
output = Array("7/2","7","14","28","3/4","3/2","3","6","12","24","1/4","1/2","1","2","4","8","64","32","16")

Dim str_1, str_2

For y = 0 to 37

For i = 0 to 18

str_1 = tt(y) & input(i)
str_2 = medio(i)
myString = Replace(myString, str_1, str_2)

Next

For i = 0 to 18
str_1 = medio(i)
str_2 = tt(y) & output(i)
myString = Replace(myString, str_1, str_2)
Next

Next

publication.nbSetVar "[result2]", " " & myString & " "

-------------------------------------------------------------------
NeobookPub: test.pub

NBW Publication Source File
(C)1993-2008 NeoSoft Corp.
Title=VBScript-Neobook speedtest
Language=US
NeoBookVer=5,60
ScreenColors=16777216
ScreenWidth=500
ScreenHeight=400
BkndColor=0
ScreenAutoSize=Yes
LinkColor=16711680
WindowStyle=0
WindowOrder=0
WindowPos=0
WindowProps=31
BiDiMode=0
UseUpdateTimer=Yes
ReturnTime=60
SubroutineAction=:replace¶¶Loop "1" "38" "[y]"¶¶ Loop "1" "19" "[z]"¶ SetVar "[str_1]" "[tt[y]][input[z]]"¶ SetVar "[str_2]" "[medio[z]]"¶ StrReplace "[myString]" "[str_1]" "[str_2]" "[myString]" "CaseSensitive"¶¶ EndLoop¶¶ Loop "1" "19" "[z]"¶¶ SetVar "[str_1]" "[medio[z]]"¶ SetVar "[str_2]" "[tt[y]][output[z]]"¶ StrReplace "[myString]" "[str_1]" "[str_2]" "[myString]" "CaseSensitive"¶ EndLoop¶¶EndLoop¶¶Return
ShapeTransColor=536870912
Icon=C:\Program Files\NeoBook 5\Icons\Dolphin.ico
CompileType=0
MediaType=0
FilesIncluded=1
FontsIncluded=2
CopyExternalFiles=No
SetupMedia=3
SetupInstDir=C:\MyProgram
SetupTitle=Setup
SetupColors=16711680|0|65535
Variables=[Factorial]¶[Factorial2]¶[FactTemp]¶[limit]¶[N]¶[NNN]¶
VersionMajor=1
VersionMinor=0
VersionRelease=0
VersionBuild=0
CustomFontName=Arial
CustomFontSize=9
CustomFontStyle=0
CustomCharset=1
CacheSize=30
ExtractOp=132
L_OK=OK
L_CANCEL=Cancel
L_YES=Yes
L_NO=No
L_CLOSE=Close
L_ERRORTITLE=Error
L_FINDTITLE=Find
L_FINDPROMPT=Find &What
L_FINDFIRST=&Find First
L_FINDNEXT=Find &Next
L_FINDERROR=Search text not found.
L_PWORDTITLE=Password required
L_PWORDMSG=Before continuing, you must first|enter the correct password.
L_PWORDPROMPT=&Password:
L_PWORDERROR=That's not the right password!
L_MEDIAERROR=In order to play this type of file you must install|the appropriate multimedia hardware and/or|software.
L_INTERNETERROR=Unable to locate Internet Browser software.
L_ABORTFUNCTION=Do you want to cancel this function?
L_EXTRACTERROR=This file could not be extracted and cannot be played.
L_INSTDIRPROMPT=Please enter the drive and directory where you would like this program to be installed. To accept the default drive and directory, simply press Enter.
L_INSTFOLDERPROMPT=Do you wish to create a program folder?
L_INSTRUNPROMPT=Do you want to run
L_INSTDISKPROMPT=Please insert disk #
L_INSTDISKERROR=That's not the correct disk, try again.
L_INSTGENERROR=The installation has terminated.
L_INSTEXITPROMPT=Do you really want to cancel the installation?
L_INSTWINTITLE=Setup
L_INSTPROGTITLE=Extracting Files...
L_SENDEMAIL=Sending Mail...
L_MAILSERVER=Please enter the name of your outgoing email server:
L_COPY=Copy to Clipboard
L_SELECTALL=Select All
L_DONWLOADFILE=Downloading: %s
L_PLEASEWAIT=Please wait...
TrayMenuBegin
MenuName=TrayOpen
MenuText=Open
MenuState=3
MenuKey=0
MenuAction=SetVar "[WindowState]" "Normal"
MenuName=TrayExit
MenuText=Exit
MenuState=3
MenuKey=0
MenuAction=Exit "" ""
MenuEnd
MasterPage
NewPage=New Page
PageStyle=0
PageColor=16777215
PageGradient1=16711680
PageGradient2=255
PageGradientDir=1
WallpaperStyle=0
EffectSpeed=0
PgEnterAction=SetVar "[selectN]" "50"¶¶SetVar "[tt_base]" "x;A;B;C;D;E;F;G;a;b;c;d;e;f;g;Z;z;A,;B,;C,;D,;E,;F,;G,;A,,;B,,;C,,;D,,;E,,;F,,;G,,;a';b';c';d';e';f';g'"¶StrParse "[tt_base]" ";" "[tt]" "[aaa]"¶SetVar "[input_base]" "8..;4..;2..;1..;32.;16.;8.;4.;2.;1.;64;32;16;8;4;2;1111;11;1"¶StrParse "[input_base]" ";" "[input]" "[bbb]"¶SetVar "[medio_base]" "xnlap;xtyec;xswlo;xkuey;kiuw;miem;wroa;prle;jleh;wroe;chie;hluc;xlap;nlup;tiec;swlu;xxxnluup;xnluup;koey"¶StrParse "[medio_base]" ";" "[medio]" "[ccc]"¶SetVar "[output_base]" "7/2;7;14;28;3/4;3/2;3;6;12;24;1/4;1/2;1;2;4;8;64;32;16"¶StrParse "[output_base]" ";" "[output]" "[ddd]"¶¶SetVar "[Original_String]" "g'1 a'1 G1 F1 G1 A1 G1 G1. A1. G1. F1. G1. A1. G1. G8 A8 G8 F8 G8 A8 G8 G8. A8. G8. F8. G8. A8. G8. G4 A4 G4 F4 G4 A4 G4 G4. A4. G4. F4. G4. A4. G4. G32. A32. G32. F32. G32. A32. G32. G32. A32. G32. F32. G32. A32. G32. G16 A16 G16 F16 G16 A16 G16 G16. A16. G16. F16. G16. A16. G16. G2 A2 G2 F2 G2 A2 G2 G,2. A,2. G,2. F,2. G,2. A,2. G,2. "
ObjectType=8
Name=Text1
X=154
Y=129
W=205
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [Factorial1]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=8
ObjectType=8
Name=Text3
X=155
Y=176
W=206
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [Factorial2]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=3
ObjectType=3
Name=PushButton1
X=18
Y=129
W=120
H=30
Anchor=0
Text=N! by Neobook
Align=2
ImageStyle=0
ObjAction=SetVar "[one_moment]" "one moment, factorial by Neobook"¶ShowObject "Text20" "None" "0"¶SetVar "[start1]" ""¶SetVar "[end1]" ""¶SetVar "[elapsed1]" ""¶SetVar "[E1]" ""¶SetVar "[start1]" "[Second]"¶¶Loop "1" "[selectN]" "[N]"¶ Math "[N]" "0" "[N]"¶ SetVar "[Factorial1]" "1"¶ If "[N]" ">" "1"¶ Loop "2" "[N]" "[FactTemp]"¶ Math "[FactTemp]*[Factorial1]" "0" "[Factorial1]"¶ EndLoop¶ EndIf¶ Math "[Factorial1]" "0" "[Factorial1]"¶EndLoop¶¶SetVar "[end1]" "[Second]"¶If "[end1]" "<" "[start1]"¶ Math "([end1]+60)-[start1]" "0" "[elapsed1]"¶Else¶ Math "[end1]-[start1]" "0" "[elapsed1]"¶EndIf¶SetVar "[E1]" "[elapsed1] seconds"¶SoundBuzzer¶HideObject "Text20" "None" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=4
ObjectType=3
Name=PushButton2
X=16
Y=174
W=121
H=30
Anchor=0
Text=N! by VBScript
Align=2
ImageStyle=0
ObjAction=SetVar "[one_moment]" "one moment, factorial by VBScript"¶ShowObject "Text20" "None" "0"¶SetVar "[start2]" ""¶SetVar "[end2]" ""¶SetVar "[elapsed2]" ""¶SetVar "[E2]" ""¶¶SetVar "[start2]" "[Second]"¶¶Call "Factorial2"¶¶SetVar "[end2]" "[Second]"¶If "[end2]" "<" "[start2]"¶ Math "([end2]+60)-[start2]" "0" "[elapsed2]"¶Else¶ Math "[end2]-[start2]" "0" "[elapsed2]"¶EndIf¶SetVar "[E2]" "[elapsed2] seconds"¶SoundBuzzer¶HideObject "Text20" "None" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=2
ObjectType=11
Name=ComboBox1
X=154
Y=71
W=61
H=24
Anchor=0
Text=50¶60¶70¶80¶90¶100
VarName=[selectN]
VarType=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=5
ObjectType=8
Name=Text4
X=15
Y=70
W=84
H=27
Anchor=0
Font=Arial
FontSize=10
FontStyle=1
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0\b Select N}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=6
ObjectType=8
Name=Text7
X=372
Y=128
W=110
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [E1]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=9
ObjectType=8
Name=Text8
X=374
Y=176
W=108
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [E2]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=11
ObjectType=8
Name=Text9
X=370
Y=101
W=97
H=26
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0\b Elapsed time }}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=15
ObjectType=8
Name=Text12
X=13
Y=-1
W=472
H=57
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 This application demonstrates the speed of VBScript in relation to \plain\f0\fs20\cf0 Neobook with the task to determine the factorial of number N after \plain\f0\fs20\cf0 determining the factorials of all foregoing numbers.}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=17
ObjectType=7
Name=Line1
X1=-1
Y1=220
X2=500
Y2=220
EndCaps=0
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=18
ObjectType=3
Name=PushButton3
X=18
Y=302
W=120
H=30
Anchor=0
Text=Replace (Neobook)
Align=2
ImageStyle=0
ObjAction=ShowObject "Text20" "None" "0"¶¶SetVar "[myString]" "[Original_String]"¶SetVar "[one_moment]" "one moment, replace by Neobook"¶¶SetVar "[result1]" ""¶SetVar "[start3]" ""¶SetVar "[end3]" ""¶SetVar "[elapsed3]" ""¶SetVar "[E3]" ""¶¶SetVar "[start3]" "[Second]"¶¶GoSub "replace"¶SetVar "[result1]" "[myString]"¶¶SetVar "[end3]" "[Second]"¶If "[end3]" "<" "[start3]"¶ Math "([end3]+60)-[start3]" "0" "[elapsed3]"¶Else¶ Math "[end3]-[start3]" "0" "[elapsed3]"¶EndIf¶SetVar "[E3]" "[elapsed3] seconds"¶¶SoundBuzzer¶HideObject "Text20" "None" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=19
ObjectType=3
Name=PushButton4
X=18
Y=349
W=122
H=30
Anchor=0
Text=Replace (VBScript)
Align=2
ImageStyle=0
ObjAction=ShowObject "Text20" "None" "0"¶¶SetVar "[myString]" "[Original_String]"¶SetVar "[one_moment]" "one moment, replace by VBScript"¶¶SetVar "[result]" ""¶SetVar "[start4]" ""¶SetVar "[end4]" ""¶SetVar "[elapsed4]" ""¶SetVar "[E4]" ""¶¶SetVar "[start4]" "[Second]"¶¶Call "ReplaceVBScript"¶¶SetVar "[end4]" "[Second]"¶¶If "[end4]" "<" "[start4]"¶ Math "([end4]+60)-[start4]" "0" "[elapsed4]"¶Else¶ Math "[end4]-[start4]" "0" "[elapsed4]"¶EndIf¶SetVar "[E4]" "[elapsed4] seconds"¶SoundBuzzer¶HideObject "Text20" "None" "0"
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=1
ObjectType=8
Name=Text15
X=379
Y=305
W=110
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [E3]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=10
ObjectType=8
Name=Text16
X=379
Y=352
W=108
H=30
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [E4]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
TabOrder=7
ObjectType=8
Name=Text19
X=11
Y=232
W=462
H=43
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 This application demonstrates the speed of VBScript in relation to \plain\f0\fs20\cf0 Neobook with the task to replace characters of a string (arrays and \plain\f0\fs20\cf0 nested loops). }}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
TabOrder=16
ObjectType=9
Name=TextEntry2
X=157
Y=304
W=205
H=30
Anchor=0
VarName=[result1]
EditMultiLine=Yes
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=21
ObjectType=9
Name=TextEntry3
X=157
Y=351
W=206
H=30
Anchor=0
VarName=[result2]
EditMultiLine=Yes
EditLen=0
LineColor=0
LineWidth=1
LineStyle=0
FillColor=16777215
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=24
ObjectType=8
Name=Text23
X=374
Y=278
W=112
H=24
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0\b Elapsed time}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=14
ObjectType=8
Name=Text29
X=153
Y=278
W=68
H=21
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0\b Result}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=13
ObjectType=8
Name=Text30
X=150
Y=100
W=68
H=24
Anchor=0
Font=Arial
FontSize=8
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\ql\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0\b Result}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=12632256
FillPattern=1
TabOrder=12
ObjectType=3
Name=PushButton9
X=454
Y=249
W=32
H=22
Anchor=0
Text=info
Align=2
ImageStyle=0
ObjAction=AlertBox "Task" "Example replace task: ||input: A1 A1.. A2 A2. A8 A16|output: A16 A28 A8 A12 A2 A1 ||the most flexible and efficient solution is then with arrays and loops.||Note: Neobook does require nearly all CPU resources. VBScript doesn't."
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=23
ObjectType=3
Name=PushButton6
X=153
Y=37
W=32
H=22
Anchor=0
Text=info
Align=2
ImageStyle=0
ObjAction=AlertBox "Task" "Needless to say, this task is a nonsense one and not necessary |to determine the factorial of N. |This inefficient task is -of course- only for demonstration purposes.||Note: Neobook does require nearly all CPU resources. VBScript doesn't."
LineColor=0
LineWidth=1
LineStyle=0
FillColor=12632256
FillPattern=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
TabOrder=22
ObjectType=8
Name=Text20
X=1
Y=0
W=499
H=399
Anchor=0
Font=Arial
FontSize=10
FontStyle=0
FontCharset=1
TextColor=0
Text={\rtf1\ansi\deff0\deftab254{\fonttbl{\f0\fnil\fcharset1 Arial;}}{\pard{\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 \par\qc\li0\fi0\ri0\sb0\sl\sa0 \plain\f0\fs20\cf0 [one_moment]}}}
HMargin=4
VMargin=4
LineColor=0
LineWidth=0
LineStyle=0
FillColor=16777215
FillPattern=0
Visible=No
TabOrder=20
reinier maliepaard
 
Posts: 30
Joined: Sat Jan 17, 2009 2:53 pm

Postby HPW » Sun Jan 18, 2009 4:30 pm

Nice comparison.
So I give ít a try with newLISP:

Code: Select all
(setq myString (nbget "[myString]" 350))
(setq tt (list "x" "A" "B" "C" "D" "E" "F" "G" "a" "b" "c" "d" "e" "f" "g" "Z" "z" "A," "B," "C," "D," "E," "F," "G," "A,," "B,," "C,," "D,," "E,," "F,," "G,," "a'" "b'" "c'" "d'" "e'" "f'" "g'"))
(setq input (list "8.." "4.." "2.." "1.." "32." "16." "8." "4." "2." "1." "64" "32" "16" "8" "4" "2" "1111" "11" "1"))
(setq medio (list "xnlap" "xtyec" "xswlo" "xkuey" "kiuw" "miem" "wroa" "prle" "jleh" "wroe" "chie" "hluc" "xlap" "nlup" "tiec" "swlu" "xxxnluup" "xnluup" "koey"))
(setq output (list "7/2" "7" "14" "28" "3/4" "3/2" "3" "6" "12" "24" "1/4" "1/2" "1" "2" "4" "8" "64" "32" "16"))
(for (y 0 37 1)
  (for (i 0 18 1)
    (setq Str_1 (string (nth y tt)(nth i input)))
    (setq Str_2 (nth i medio))
    (setq myString (replace Str_1 myString Str_2))
  )
  (for (i 0 18 1)
    (setq Str_1 (nth i medio))
    (setq Str_2 (string (nth y tt)(nth i output)))
    (setq myString (replace Str_1 myString Str_2))
  )
)
(nbset "[result3]" myString)


I made a comparsion with the vbscript and both show 0 seconds.
I put a 1000 loop around both calls and vbscript takes 10 seconds and newLISP 7 seconds.
:wink:
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany


Return to NeoBook Functions - VBScript & JavaScript

Who is online

Users browsing this forum: No registered users and 1 guest