[BENCHMARKS]
* NEW: Add a new 'string' benchmark. git-svn-id: svn://localhost/gambas/trunk@7442 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
8c51cc2d2c
commit
0b70c0d37c
3 changed files with 62 additions and 0 deletions
21
benchmark/string.gbs
Executable file
21
benchmark/string.gbs
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env gbs3
|
||||||
|
|
||||||
|
Dim S As String = "abcdefgh" & "efghefgh"
|
||||||
|
Dim M As Integer = (1024 \ Len(S)) * 768
|
||||||
|
Dim G As String
|
||||||
|
Dim I As Integer
|
||||||
|
Dim L As Integer
|
||||||
|
Dim F As Float = Timer
|
||||||
|
|
||||||
|
While I < M + 1000
|
||||||
|
|
||||||
|
Inc I
|
||||||
|
G &= S
|
||||||
|
G = Replace(G, "efgh", "____")
|
||||||
|
L = Len(S) * I
|
||||||
|
If L Mod (1024*256) = 0 Then
|
||||||
|
Print CInt(Timer - F);"sec\t\t";L \ 1024;"kb"
|
||||||
|
Flush
|
||||||
|
Endif
|
||||||
|
|
||||||
|
Wend
|
18
benchmark/string.pl
Executable file
18
benchmark/string.pl
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
my $str='abcdefgh'.'efghefgh';
|
||||||
|
my $imax=1024/length($str)*768;
|
||||||
|
|
||||||
|
my $starttime=time();
|
||||||
|
|
||||||
|
my $gstr='';
|
||||||
|
my $i=0;
|
||||||
|
|
||||||
|
while($i++ < $imax+1000){ #adding 1000 iterations to delay exit. This will allow to capture memory usage on last step
|
||||||
|
|
||||||
|
$gstr.=$str;
|
||||||
|
$gstr=~s/efgh/____/g;
|
||||||
|
my $lngth=length($str)*$i; ## my $lngth=length($gstr); # Perhaps that would be a slower way
|
||||||
|
print time()-$starttime,"sec\t\t",$lngth/1024,"kb\n" unless $lngth % (1024*256); #print out every 256kb
|
||||||
|
}
|
||||||
|
|
23
benchmark/string.py
Executable file
23
benchmark/string.py
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
|
||||||
|
import re
|
||||||
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
|
str = 'abcdefgh'+'efghefgh'
|
||||||
|
imax = 1024/len(str)*768
|
||||||
|
|
||||||
|
starttime = time.time();
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
gstr = ''
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while (i < imax+1000):
|
||||||
|
i = i + 1
|
||||||
|
gstr += str
|
||||||
|
gstr = re.sub('efgh','____',gstr)
|
||||||
|
lngth = len(str) * i
|
||||||
|
if (lngth % (1024*256) == 0):
|
||||||
|
print int(time.time()-starttime),"sec\t\t",(lngth/1024),"kb"
|
||||||
|
sys.stdout.flush()
|
Loading…
Reference in a new issue