Why is BlitzPlus so much slower than Blitz2D?

BlitzPlus Forums/BlitzPlus Programming/Why is BlitzPlus so much slower than Blitz2D?

I tried your program on 1000 elements in BlitzPlus. It took 22 seconds.

I'm not sure what to make of that.
Here's one of my old test programs from the early days of Blitz Basic(2d).

I just tried it on 100,000 elements in Blitz3D and BlitzPlus.
Times are about the same, a little under .3 seconds.

; Demonstration of the HeapSort algorithm. 
; A large array of random integers is sorted into non-decreasing order.

Graphics 640, 480, 0, 2

Global n = 1000 * 100		; number of integers to sort
Dim a(n)			; a(1..n) holds the integers, a(0) is ignored

heaptest()
WaitKey()
End


Function heaptest()	; fill in random data, do the sort and display results
Local t#
  Text 10, 10, "Filling in random data..."
  initialize()
  Text 200, 10, "Done."
  Text 10, 30, "Beginning sort...  "
  t#=MilliSecs()
  heapsort()
  t#=MilliSecs()-t#
  Text 200, 30, "Done."
  Text 10, 50, "Verifying correctness of sort: "
  If IsSorted() Then
	Text 10, 90, "Success."
	Text 10, 120, n+" integers sorted in "+t#/1000+" seconds"
  Else
	Text 10, 140, "Failure."	; this should never happen
  EndIf
End Function

Function initialize()
; fill array a(1..n) with some random integers
  Local i
  For i=1 To n
    a(i)=Rnd(1000000)
  Next 
End Function

Function IsSorted()		; are a(1) to a(n) in non-decreasing order?
Local i
  For i=1 To n-1
    If a(i)>a(i+1) Then Return False	; out of order, should never happen
  Next
  Return True
End Function


; ********* all the work is done with these two functions

; This is for integers but could be easily modified to handle any
; kind of data, even types. The only changes needed are to the code
; to swap two elements and the code to compare two elements. 

Function heapsort()     ; the array a(1..n)     Note: a() and n are Global
  Local i,n2,temp
  n2=n			; save a copy of the original n
  For i=n-1 To 1 Step -1
    heapify(i)
  Next 
  While n>1
    temp=a(1) : a(1)=a(n) : a(n)=temp		; swap a(1),a(n)
    n=n-1
    heapify(1)
  Wend
  n=n2
End Function

Function heapify(i)		; everything below node i is already a heap
  Local j,k,temp
  j=i+i
  If j<=n
    k=j+1
    If k<=n
      If a(k)>a(j)
        temp=j : j=k : k=temp
      EndIf
    EndIf
    If a(i)<a(j)
      temp=a(i) : a(i)=a(j) : a(j)=temp
      heapify(j)
    EndIf
  EndIf
End Function


Edit: I just noticed where most of the time is spent.

There is a call to KeyDown() inside the sort. This is using almost 90% of the time.
Getting rid of it cuts the time to 3 seconds.

That's still slow, but you can blame the algorithm.