here is the source code from B4J (b4x.com):
Code: Select all
'Non-UI application (console / server application)
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
Sub Process_Globals
Public fCount As Int: fCount = 1024
Public fArrayA(fCount,fCount) As Double
Public fArrayB(fCount,fCount) As Double
Public fArrayC(fCount,fCount) As Double
Public BenchmarkTests,i,j,k As Int
Public tmp As String
End Sub
Sub AppStart (Args() As String)
Log($"B4J Matrix Multiplication Benchmark started. Please wait..."$)
Dim start As Long = DateTime.Now
' Add random values to Arrays A and B (0 to 1)
For BenchmarkTests = 0 To 4
For i = 0 To fCount-1
For j = 0 To fCount-1
fArrayA(i,j) = Rnd(0,1)
fArrayB(i,j) = Rnd(0,1)
fArrayC(i,j) = 0
Next
Next
' Multiply A to B values and add them to C
For i = 0 To fCount -1
For j = 0 To fCount -1
For k = 0 To fCount -1
fArrayC(i,j) = (fArrayC(i,j) + fArrayA(i,k)) * fArrayB(k,j)
Next
Next
Next
Next
Log($"B4J Matrix Muliplication Benchmark finished in: ${DateTime.Now - start}ms"$)
End Sub
We are not in a competition here!
Optimized code generation
While FreeBASIC is not an optimizing compiler, it does many kinds of general optimizations to generate the fastest possible code on x86 CPU's, not losing to other BASIC alternatives, including the commercial ones. Completely free All third-party tools are also free. No piece of abandoned or copyrighted software is used (except GoRC on Win32). The assembler, linker, archiver, and other command-line applications come from the GNU binutils programming tools.