I finally cut, pasted, recompiled a console only test program. I compiled my test program with FB 0.16b and FB 0.18.3b. The 0.18.3b .exe is 14 time slower than the 0.16b .exe.

My t1-t0 times were, 0.16b - 1.2538, 0.18.3b - 19.0089, AMD Sempron 2600.

I do not know what the problem is.

Help appreciated.

JohnB

test.bas

Code: Select all

`'`

'

' compile using fbc -s console test.bas

'

'

Const PI = 3.1415926535897932384626

Type __VECTOR__

x As single

y As single

z As single

End Type

dim shared as integer LEVEL1_DETAIL, LEVEL2_DETAIL, LEVEL3_DETAIL, LEVEL4_DETAIL

LEVEL1_DETAIL = 10

LEVEL2_DETAIL = 20

LEVEL3_DETAIL = 40

LEVEL4_DETAIL = 80

declare function getHeight(byval x as integer, byval y as integer) as double

declare function interpolate(a as double, b as double, x as double) as double

declare function noise(x as integer, y as integer) as double

declare function SmoothedNoise(x as integer, y as integer) as double

declare function InterpolatedNoise1(x as integer, y as integer) as double

declare function InterpolatedNoise2(x as integer, y as integer) as double

declare function InterpolatedNoise3(x as integer, y as integer) as double

declare function InterpolatedNoise4(x as integer, y as integer) as double

dim shared as integer fw, fh

fw = 256

fh = 256

function getHeight(byval x as integer, byval y as integer) as double

dim as double h

x=abs(x)

y=abs(y)

h = tan(InterpolatedNoise1(x, y) * 1.000 + _

InterpolatedNoise2(x, y) * 0.500 + _

InterpolatedNoise3(x, y) * 0.250 + _

InterpolatedNoise4(x, y) * 0.125)

h += 0.5

h = 3 * h^2 - 2 * h^3

return h

end function

function interpolate(a as double, b as double, x as double) as double

dim as double ft, f

ft = x * PI

f = (1 - cos(ft)) * .5

return a*(1-f) + b*f

end function

function noise(x as integer, y as integer) as double

if x>-1 and y>-1 then

randomize 1+x*y+sin(x)*128+cos(y)*128

return rnd * 2 - 1

else

return 0

end if

end function

function SmoothedNoise(x as integer, y as integer) as double

dim as double corners, sides, center

corners = ( noise(x-1, y-1)+noise(x+1, y-1)+noise(x-1, y+1)+noise(x+1, y+1) ) / 16

sides = ( noise(x-1, y) +noise(x+1, y) +noise(x, y-1) +noise(x, y+1) ) / 8

center = noise(x, y) / 4

return corners + sides + center

end function

function InterpolatedNoise4(x as integer, y as integer) as double

dim as double lx, ly, rx, ry, px, py, h, i1, i2

dim as integer nx, ny

lx = x

ly = y

nx = int(lx / fw * LEVEL4_DETAIL)

ny = int(ly / fh * LEVEL4_DETAIL)

rx = fw / LEVEL4_DETAIL

ry = fh / LEVEL4_DETAIL

px = (lx - (nx * rx)) / rx

py = (ly - (ny * ry)) / ry

i1 = interpolate(SmoothedNoise(nx, ny), SmoothedNoise(nx + 1, ny), px)

i2 = interpolate(SmoothedNoise(nx, ny + 1), SmoothedNoise(nx + 1, ny + 1), px)

h = interpolate(i1, i2, py)

return h

end function

function InterpolatedNoise3(x as integer, y as integer) as double

dim as double lx, ly, rx, ry, px, py, h, i1, i2

dim as integer nx, ny

lx = x

ly = y

nx = int(lx / fw * LEVEL3_DETAIL)

ny = int(ly / fh * LEVEL3_DETAIL)

rx = fw / LEVEL3_DETAIL

ry = fh / LEVEL3_DETAIL

px = (lx - (nx * rx)) / rx

py = (ly - (ny * ry)) / ry

i1 = interpolate(SmoothedNoise(nx, ny), SmoothedNoise(nx + 1, ny), px)

i2 = interpolate(SmoothedNoise(nx, ny + 1), SmoothedNoise(nx + 1, ny + 1), px)

h = interpolate(i1, i2, py)

return h

end function

function InterpolatedNoise2(x as integer, y as integer) as double

dim as double lx, ly, rx, ry, px, py, h, i1, i2

dim as integer nx, ny

lx = x

ly = y

nx = int(lx / fw * LEVEL2_DETAIL)

ny = int(ly / fh * LEVEL2_DETAIL)

rx = fw / LEVEL2_DETAIL

ry = fh / LEVEL2_DETAIL

px = (lx - (nx * rx)) / rx

py = (ly - (ny * ry)) / ry

i1 = interpolate(SmoothedNoise(nx, ny), SmoothedNoise(nx + 1, ny), px)

i2 = interpolate(SmoothedNoise(nx, ny + 1), SmoothedNoise(nx + 1, ny + 1), px)

h = interpolate(i1, i2, py)

return h

end function

function InterpolatedNoise1(x as integer, y as integer) as double

dim as double lx, ly, rx, ry, px, py, h, i1, i2

dim as integer nx, ny

lx = x

ly = y

nx = int(lx / fw * LEVEL1_DETAIL)

ny = int(ly / fh * LEVEL1_DETAIL)

rx = fw / LEVEL1_DETAIL

ry = fh / LEVEL1_DETAIL

px = (lx - (nx * rx)) / rx

py = (ly - (ny * ry)) / ry

i1 = interpolate(SmoothedNoise(nx, ny), SmoothedNoise(nx + 1, ny), px)

i2 = interpolate(SmoothedNoise(nx, ny + 1), SmoothedNoise(nx + 1, ny + 1), px)

h = interpolate(i1, i2, py)

return h

end function

Dim Shared As Integer x, y

Dim As Double t0, t1

Dim Shared As __VECTOR__ map

Dim Shared As Double RenderGrid(0 To 128,0 To 128)

map.x = 32768

map.y = 32768

Print "start"

t0 = Timer

for y = 0 to 128

for x = 0 to 128

RenderGrid(x, y)=getHeight(x+map.x, y+map.y)

next

next

t1 = Timer

Print t0,t1,t1-t0

Sleep