Hi All,
I've just started developing in AppGameKit and my burning question has been - how much faster is Tier 2 than Tier 1 (for something simple like a particle simulation with sprites).
The answer was surprising to me in many ways.
Test Platform:
Intel i7-6700l
NVidia GTX 1080
Windows 10 Latest Update / Latest NVidia Drivers 419.17.
3840x2160 Philips Display
Simple Test:
Move as many 8x8 sprites as possible keeping FPS at 59.9. Bounce sprites at edge of screen.
Result:
Tier 1: Approx 20,000 sprites
Tier 2: Approx 23,000 sprites
So there doesn't seem like much of a difference. However this test created more questions.
I could run both the Tier 1 & Tier 2 text executables simulateously and get the same performance from both.
Opening the task manager showed that both were using appoximately 15% CPU and 14% GPU.
Are the test applications being throttled somehow?
--------------------------
AGK Code
// Project: benchmark
// Created: 2019-02-27
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "benchmark" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 0, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
//UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
local img as integer
img=1
local max as integer
max=20000
dim spr[max] as integer
dim xvel[max] as float
dim yvel[max] as float
local x as float
local y as float
Loadimage(1,"smile.png")
for a=1 to max-1
CreateSprite(a,1)
SetSpritePosition(a,10,50)
xvel[a]=Random(1,1000)
xvel[a]=xvel[a]/1000
yvel[a]=Random(1,1000)
yvel[a]=yvel[a]/1000
next a
do
for a=1 to max-1
x=GetSpriteX(a)
y=GetSpriteY(a)
x = x + xvel[a]
y = y + yvel[a]
if (x > 1024) or (x < 0)
xvel[a]=-xvel[a]
x = x + xvel[a]
endif
if (y > 768) or (y < 0)
yvel[a]=-yvel[a]
y = y + yvel[a]
endif
SetSpritePosition(a,x,y)
next a
Print( ScreenFPS() )
Sync()
loop
C++ Code
// Includes
#include "template.h"
// Namespace
using namespace AGK;
app App;
const int max = 23000;
int img;
int spr[max];
float xvel[max];
float yvel[max];
void app::Begin(void)
{
agk::SetWindowSize(1024, 768, 1);
agk::SetVirtualResolution (1024, 768);
agk::SetClearColor( 0,0,0 );
agk::SetSyncRate(60,0);
agk::SetScissor(0,0,0,0);
img = agk::LoadImage("smile.png");
for (int a = 0; a < max; a++ ) {
spr[a] = agk::CreateSprite(img);
//agk::SetSpritePosition(spr[a], agk::Random(100,200), agk::Random(100, 200));
agk::SetSpritePosition(spr[a], 10, 50);
xvel[a] = (float) agk::Random(1, 1000) / 1000;
yvel[a] = (float) agk::Random(1, 1000) / 1000;
}
}
int app::Loop (void)
{
//agk::Print("Hello, AppGameKit!");
agk::Print(agk::Str(agk::ScreenFPS()));
for (int a = 0; a < max; a++) {
float x = agk::GetSpriteX(spr[a]);
float y = agk::GetSpriteY(spr[a]);
x = x + xvel[a];
y = y + yvel[a];
if ((x > 1024) || (x < 0)) {
xvel[a] = -xvel[a];
x = x + xvel[a];
}
if ((y > 768) || (y < 0)) {
yvel[a] = -yvel[a];
y = y + yvel[a];
}
agk::SetSpritePosition(spr[a], x, y);
}
agk::Sync();
if (agk::GetRawKeyState(27) == 1) {
return 1;
}
return 0; // return 1 to close app
}
void app::End (void)
{
}