Compute the duration of JIT Gambas code without JIT compilation time.

[BENCHMARKS]
* NEW: Compute the duration of JIT Gambas code without JIT compilation time.
This commit is contained in:
gambas 2018-07-03 00:54:34 +02:00
parent 4a1c81d0aa
commit 6fc6a48818
7 changed files with 24 additions and 3 deletions

View File

@ -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 "<table class=\"table\">"
Print "<tr>\n<th>Benchmark</th>"
For Each sLang In ["Python", "Perl", "Gambas", "Gambas + JIT"]
For Each sLang In ["Python", "Perl", "Gambas", "Gambas JIT", "Gambas JIT without compilation time"]
Print "<th style=\"width:12em;\">"; Html(sLang); "</th>"
Next
Print "</tr>"
@ -119,6 +127,7 @@ Else
Print "<td align=\"right\">"; FormatResult(cResult, "perl"); "&nbsp;</td>"
Print "<td align=\"right\">"; FormatResult(cResult, "gambas"); "&nbsp;</td>"
Print "<td align=\"right\">"; Format(cResult!gambasjit, "0.00"); "&nbsp;</td>"
Print "<td align=\"right\">"; Format(cResult!gambasjitwct, "0.00"); "&nbsp;</td>"
Print "</tr>"
Next
Print "</table>"

View File

@ -75,3 +75,6 @@ Dim I As Integer
For I = 1 To 20
Mandelbrot(200, 200)
Next
Error CStr(Jit.Time)

View File

@ -208,3 +208,5 @@ Next
Print S.Energy()
Error CStr(Jit.Time)

View File

@ -31,3 +31,4 @@ For I = 1 To 2
Print Test(0.2)
Next
Error CStr(Jit.Time)

View File

@ -57,3 +57,5 @@ For I = 1 To 5
Next
Print Format(Timer - T, "0.000 s")
Error CStr(Jit.Time)

View File

@ -65,3 +65,5 @@ For I = 0 to 999
Print aTab[I];;
Next
Print
Error CStr(Jit.Time)

View File

@ -19,3 +19,5 @@ While I < M + 1000
Endif
Wend
Error CStr(Jit.Time)