From 0b70c0d37c329be0a0bb667c0faa6a8808fdc000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Minisini?= Date: Tue, 3 Nov 2015 02:02:47 +0000 Subject: [PATCH] [BENCHMARKS] * NEW: Add a new 'string' benchmark. git-svn-id: svn://localhost/gambas/trunk@7442 867c0c6c-44f3-4631-809d-bfa615b0a4ec --- benchmark/string.gbs | 21 +++++++++++++++++++++ benchmark/string.pl | 18 ++++++++++++++++++ benchmark/string.py | 23 +++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 benchmark/string.gbs create mode 100755 benchmark/string.pl create mode 100755 benchmark/string.py diff --git a/benchmark/string.gbs b/benchmark/string.gbs new file mode 100755 index 000000000..3b0b7b4a9 --- /dev/null +++ b/benchmark/string.gbs @@ -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 \ No newline at end of file diff --git a/benchmark/string.pl b/benchmark/string.pl new file mode 100755 index 000000000..4d9b1bef5 --- /dev/null +++ b/benchmark/string.pl @@ -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 +} + diff --git a/benchmark/string.py b/benchmark/string.py new file mode 100755 index 000000000..0b35342ed --- /dev/null +++ b/benchmark/string.py @@ -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()