Took twice as long with PureBasic...?

Unless there's a mistake in the code (rather than just saying sorting is a dumb way to test speed).
PureBasic
Code: Select all
Procedure bubbleSort(Array arr.i(1))
swapped.b = #True
max.i = ArraySize(arr()) - 1
While (swapped = #True)
swapped = #False
For i.i = 0 To max
If arr(i) > arr(i + 1)
temp.i = arr(i)
arr(i) = arr(i + 1)
arr(i + 1) = temp
swapped = #True
EndIf
Next i
max = max - 1
Wend
EndProcedure
OpenConsole()
size.l = 50000
PrintN("Bubble Sort Test..." + Str(size))
; Intialize array of random numbers
Dim bubs.i(size)
For i.i = 0 To size
bubs(i) = Random(1000000)
Next
; Initial time
time.l = ElapsedMilliseconds()
; Sort using bubble sort
bubbleSort(bubs())
; Print time elapsed
PrintN("Time to Complete: " + Str(ElapsedMilliseconds() - time))
For i.i = 9000 To 9020
PrintN(Str(bubs(i)))
Next i
Input()
CloseConsole()
Code: Select all
public class BubbleTest
{
public static void main(String[] args)
{
final int size = 50000;
System.out.println("Bubble Sort Test..." + size);
int[] bubs = new int[size];
for (int i = 0; i < size; i++)
bubs[i] = (int) (Math.random() * 10000000);
long time = System.currentTimeMillis();
bubbleSort(bubs);
System.out.println("Time to Complete: " + (System.currentTimeMillis() - time));
for (int i = 2000; i < 2020; i++)
System.out.println(bubs[i]);
}
public static void bubbleSort(int[] arr)
{
int len = arr.length;
boolean swapped = true;
while (swapped == true)
{
swapped = false;
for (int i = 0; i < len - 1; i++)
{
if (arr[i] > arr[i + 1])
{
int temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
swapped = true;
}
}
len--;
}
}
}