From 6fc6a48818a17164817a823d80dba3358ad9ba89 Mon Sep 17 00:00:00 2001 From: gambas Date: Tue, 3 Jul 2018 00:54:34 +0200 Subject: [PATCH] Compute the duration of JIT Gambas code without JIT compilation time. [BENCHMARKS] * NEW: Compute the duration of JIT Gambas code without JIT compilation time. --- benchmark/benchmark.gbs | 15 ++++++++++++--- benchmark/mandelbrot.gbs | 3 +++ benchmark/nbody.gbs | 2 ++ benchmark/polynom.gbs | 1 + benchmark/primes.gbs | 2 ++ benchmark/sort.gbs | 2 ++ benchmark/string.gbs | 2 ++ 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/benchmark/benchmark.gbs b/benchmark/benchmark.gbs index 02b685b03..ff39a0263 100755 --- a/benchmark/benchmark.gbs +++ b/benchmark/benchmark.gbs @@ -1,7 +1,10 @@ #!/usr/bin/env gbs3 +Private $fCompileTime as Float + Private Sub RunScript(sScript As String, sRun As String, bGambasOnly As Boolean) As Float + Dim aResult as String[] Dim sResult As String Dim fTime As Float @@ -13,13 +16,17 @@ Private Sub RunScript(sScript As String, sRun As String, bGambasOnly As Boolean) Shell "/usr/bin/time -v " & sRun & " " & sScript & " 2>&1 >/dev/null" To sResult If Not sResult Then Error.Raise("Script '" & sRun & " " & sScript & "' failed!") - For Each sResult In Split(sResult, "\n") + aResult = Split(sResult, "\n") + For Each sResult In aResult sResult = Trim(sResult) If sResult Begins "User time" Or If sResult Begins "System time" Then fTime += CFloat(Mid$(sResult, InStr(sResult, ":") + 2)) Endif Next + $fCompileTime = 0 + Try $fCompileTime = CFloat(Trim(aResult[0])) + Return fTime End @@ -74,6 +81,7 @@ For Each sBenchmark In Dir(Application.Dir, "*.gbs") cResult!name = sBenchmark cResult!gambasjit = RunScript(sBenchmark & ".gbs", "gbs3 -f -c", bGambasOnly) + cResult!gambasjitwct = cResult!gambasjit - $fCompileTime cResult!gambas = RunScript(sBenchmark & ".gbs", "gbs3 -c", bGambasOnly) If Not bGambasOnly Then cResult!python = RunScript(sBenchmark & ".py", "python", bGambasOnly) If Not bGambasOnly Then cResult!perl = RunScript(sBenchmark & ".pl", "perl", bGambasOnly) @@ -101,14 +109,14 @@ Next If bGambasOnly Then For Each cResult In aResult - Print cResult!name; Space$(20 - Len(cResult!name)); ": "; Format(cResult!gambas, "0.00"); " / ";Format(cResult!gambasjit, "0.00");" (jit)" + Print cResult!name; Space$(20 - Len(cResult!name)); ": "; Format(cResult!gambas, "0.00"); " / ";Format(cResult!gambasjit, "0.00");" (jit)"; " / ";Format(cResult!gambasjitwct, "0.00");" (jit without compilation time)" Next Else Print "" Print "\n" - For Each sLang In ["Python", "Perl", "Gambas", "Gambas + JIT"] + For Each sLang In ["Python", "Perl", "Gambas", "Gambas JIT", "Gambas JIT without compilation time"] Print "" Next Print "" @@ -119,6 +127,7 @@ Else Print "" Print "" Print "" + Print "" Print "" Next Print "
Benchmark"; Html(sLang); "
"; FormatResult(cResult, "perl"); " "; FormatResult(cResult, "gambas"); " "; Format(cResult!gambasjit, "0.00"); " "; Format(cResult!gambasjitwct, "0.00"); " 
" diff --git a/benchmark/mandelbrot.gbs b/benchmark/mandelbrot.gbs index f4e4662dc..8fe74e136 100755 --- a/benchmark/mandelbrot.gbs +++ b/benchmark/mandelbrot.gbs @@ -75,3 +75,6 @@ Dim I As Integer For I = 1 To 20 Mandelbrot(200, 200) Next + +Error CStr(Jit.Time) + diff --git a/benchmark/nbody.gbs b/benchmark/nbody.gbs index 51338c3a9..295c4be8f 100755 --- a/benchmark/nbody.gbs +++ b/benchmark/nbody.gbs @@ -208,3 +208,5 @@ Next Print S.Energy() +Error CStr(Jit.Time) + diff --git a/benchmark/polynom.gbs b/benchmark/polynom.gbs index 85bfa824a..9bd0d70bf 100755 --- a/benchmark/polynom.gbs +++ b/benchmark/polynom.gbs @@ -31,3 +31,4 @@ For I = 1 To 2 Print Test(0.2) Next +Error CStr(Jit.Time) diff --git a/benchmark/primes.gbs b/benchmark/primes.gbs index 34363921c..0b3314381 100755 --- a/benchmark/primes.gbs +++ b/benchmark/primes.gbs @@ -57,3 +57,5 @@ For I = 1 To 5 Next Print Format(Timer - T, "0.000 s") + +Error CStr(Jit.Time) diff --git a/benchmark/sort.gbs b/benchmark/sort.gbs index 47965c3d3..5a63ed813 100755 --- a/benchmark/sort.gbs +++ b/benchmark/sort.gbs @@ -65,3 +65,5 @@ For I = 0 to 999 Print aTab[I];; Next Print + +Error CStr(Jit.Time) diff --git a/benchmark/string.gbs b/benchmark/string.gbs index bf2ab26d6..5c936a589 100755 --- a/benchmark/string.gbs +++ b/benchmark/string.gbs @@ -19,3 +19,5 @@ While I < M + 1000 Endif Wend + +Error CStr(Jit.Time)