![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
This is a discussion on General Lua Discussion Thread [Not For Help] within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; To advocate PGE Lua, I decided to benchmark it against other Luaplayer version to see how it compares in terms ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#31 |
![]() ![]() |
To advocate PGE Lua, I decided to benchmark it against other Luaplayer version to see how it compares in terms of speed. First benchmark is blitting speed. I'll do a font, sprite and maby a memory one later.
Enjoy: ![]() ![]() As expected, PGE Lua is more than 4 times as fast as standard Luaplayer. Interestingly, LuaPlayerHM7 was only marginally faster than (the infamously slow) Luaplayer 0.20, even though it is meant to be based on the graphics code of Luaplayer 0.16. Anyway, for those interested, 4 tests were run each, and results averaged between them (didn't really have much of an effect, as each test was usually within 0.01 seconds of each other) Code used: For LuaplayerHM, Luaplayer 0.16 and Luaplayer 0.20: Code:
ITERATIONS = 100
SPRITECOUNT = 1000
SCREENWIDTH = 480
SCREENHEIGHT = 272
black = Color.new(0,0,0)
white = Color.new(255,255,255)
math.randomseed(os.time())
sprites = {img = Image.load("asprite.png")}
for i=1, SPRITECOUNT do
sprites[i] = {x = math.random(SCREENWIDTH),y = math.random(SCREENHEIGHT), mx = math.random(-6,6) / 3, my = math.random(-6,6) / 3}
end
starttime = os.clock()
for j = 1, ITERATIONS do
screen:clear(white)
for i,sprite in ipairs(sprites) do
sprites[i].x,sprites[i].y = sprites[i].x + sprites[i].mx, sprites[i].y + sprites[i].my
if sprite.x < 0 or sprite.y > SCREENWIDTH then
sprites[i].mx = -sprites[i].mx
end
if sprite.y < 0 or sprite.y > SCREENHEIGHT then
sprites[i].my = -sprites[i].my
end
screen:blit(sprite.x,sprite.y, sprites.img)
end
screen.flip()
end
endtime = os.clock()
screen:clear(black)
screen:print(10, 10, endtime - starttime, white)
screen.waitVblankStart()
screen.flip()
while true do
pad = Controls.read()
--System.sleep(500)
screen.waitVblankStart(30)
if pad:start() then break end
end
Code:
ITERATIONS = 100
SPRITECOUNT = 1000
SCREENWIDTH = 480
SCREENHEIGHT = 272
white = Color.new(255,255,255,255)
black = Color.new(0,0,0,255)
math.randomseed(os.time())
sprites = {img = Image.load("asprite.png", 1)}
for i=1, SPRITECOUNT do
sprites[i] = {x = math.random(SCREENWIDTH),y = math.random(SCREENHEIGHT), mx = math.random(-6,6) / 3, my = math.random(-6,6) / 3}
end
screen.init()
starttime = os.clock()
for j = 1, ITERATIONS do
screen.startDraw()
screen.clear(white)
for i,sprite in ipairs(sprites) do
sprites[i].x,sprites[i].y = sprites[i].x + sprites[i].mx, sprites[i].y + sprites[i].my
if sprite.x < 0 or sprite.y > SCREENWIDTH then
sprites[i].mx = -sprites[i].mx
end
if sprite.y < 0 or sprite.y > SCREENHEIGHT then
sprites[i].my = -sprites[i].my
end
Image.blit(sprite.x,sprite.y, sprites.img)
end
screen.endDraw()
screen.flipscreen()
end
endtime = os.clock()
screen.startDraw()
screen.print(10, 10, tostring(endtime - starttime), 1, white, black)
screen.endDraw()
screen.flipscreen()
while not Controls.read():start() do
end
Code:
ITERATIONS = 100
SPRITECOUNT = 1000
SCREENWIDTH = 480
SCREENHEIGHT = 272
white = pgeGfx.createcolor(255, 255, 255)
black = pgeGfx.createcolor(0, 0, 0)
monaco8 = pgeFont.load("monaco.ttf", 9, PGE_VRAM)
math.randomseed(os.time())
sprites = {img = pgeTexture.load("asprite.png",PGE_VRAM)}
for i=1, SPRITECOUNT do
sprites[i] = {x = math.random(SCREENWIDTH),y = math.random(SCREENHEIGHT), mx = math.random(-6,6) / 3, my = math.random(-6,6) / 3}
end
pgeGfx.startdrawing()
sprites.img:activate()
pgeGfx.enddrawing()
starttime = os.clock()
for j = 1, ITERATIONS do
pgeGfx.startdrawing()
pgeGfx.clearscreen(white)
for i,sprite in ipairs(sprites) do
sprites[i].x,sprites[i].y = sprites[i].x + sprites[i].mx, sprites[i].y + sprites[i].my
if sprite.x < 0 or sprite.y > SCREENWIDTH then
sprites[i].mx = -sprites[i].mx
end
if sprite.y < 0 or sprite.y > SCREENHEIGHT then
sprites[i].my = -sprites[i].my
end
sprites.img:draw(sprite.x,sprite.y)
end
pgeGfx.enddrawing()
pgeGfx.swapbuffers(false)
end
endtime = os.clock()
pgeGfx.startdrawing()
monaco8:activate()
pgeGfx.enddrawing()
while pge.running() do
pgeControls.update()
if pgeControls.held(PGE_CTRL_START) then break end
pgeGfx.clearscreen()
monaco8:print(10, 10, white, tostring(endtime - starttime))
pgeGfx.enddrawing()
pgeGfx.swapbuffers()
end
For Alpha tests: And for Non-Alpha tests: Last edited by Nielkie; 08-22-2008 at 09:54 PM.. |
|
|
|
|
|
#32 | |
![]() ![]() Developer
|
Thanks for that test Nielkie
![]() That PGE Lua test isn't as optimised as it could be: Code:
ITERATIONS = 100
SPRITECOUNT = 1000
SCREENWIDTH = 480
SCREENHEIGHT = 272
white = pgeGfx.createcolor(255, 255, 255)
black = pgeGfx.createcolor(0, 0, 0)
monaco8 = pgeFont.load("monaco.ttf", 9, PGE_VRAM)
if not monaco8 then
error("Failed to load font.")
end
math.randomseed(os.time())
-- Changed from PGE_RAM to PGE_VRAM
sprites = {img = pgeTexture.load("asprite.png",PGE_VRAM)}
for i=1, SPRITECOUNT do
sprites[i] = {x = math.random(SCREENWIDTH),y = math.random(SCREENHEIGHT), mx = math.random(-6,6) / 3, my = math.random(-6,6) / 3}
end
starttime = os.clock()
-- Moved this line out of the loop, texture only needs activating once, even for multiple blits.
pgeGfx.startdrawing()
sprites.img:activate()
pgeGfx.enddrawing()
for j = 1, ITERATIONS do
pgeGfx.startdrawing()
pgeGfx.clearscreen(white)
for i,sprite in ipairs(sprites) do
sprites[i].x,sprites[i].y = sprites[i].x + sprites[i].mx, sprites[i].y + sprites[i].my
if sprite.x < 0 or sprite.y > SCREENWIDTH then
sprites[i].mx = -sprites[i].mx
end
if sprite.y < 0 or sprite.y > SCREENHEIGHT then
sprites[i].my = -sprites[i].my
end
sprites.img:draw(sprite.x,sprite.y)
end
pgeGfx.enddrawing()
pgeGfx.swapbuffers(false) -- Added the false to not wait for vblank
end
endtime = os.clock()
while pge.running() do
pgeControls.update()
if pgeControls.held(PGE_CTRL_START) then break end
pgeGfx.clearscreen()
monaco8:activate()
monaco8:print(10, 10, white, tostring(endtime - starttime))
pgeGfx.enddrawing()
pgeGfx.swapbuffers()
end
__________________
![]() Check out my homebrew & C tutorials at http://insomniac.0x89.org/ Coder formerly known as Insomniac197 Quote:
Last edited by Insert_Witty_Name; 07-22-2008 at 06:43 AM.. |
|
|
|
|
|
|
#34 |
![]() ![]() Developer
|
Note that I just edited the optimised code, the texure:activate() call must be within a startdrawing() and enddrawing() block.
Activating a texture uploads it to the GE so that it can be used for texturing. Whether you're drawing once or a thousand times, it only needs doing once. Note that activating a font or a texture both use the same space, so if you activate a font at any time, the texture that was activated previously will be replaced with the font and vice versa. Hope that makes sense. |
|
|
|
|
|
#36 |
![]() |
I'm not doubting that the PGELua is much faster or that the original test was not as optimized as it could have been, but I will argue that the regular lua test was also far from perfectly optimized. I doubt the possible changes would make a significant difference, but it would certainly show up at least after the decimal.
Perhaps tests with a simple Gu.blit function might also help show whether the GU is worth using for small sprites or not? I've found that for > 5-10 sprites all which are small (<64x64) using a simple Gu.blit function with Gu.SPRITES, the Gu begins making up for its lost time starting and ending. Code:
function Gu.blit(x,y,img)
local w = img:width()
local h = img:height()
Gu.enable(Gu.TEXTURE_2D)
Gu.texImage(img)
Gum.drawArray(Gu.SPRITES, Gu.TEXTURE_32BITF+Gu.VERTEX_32BITF+Gu.TRANSFORM_2D,{{0,0,x,y,0},{w,h,w+x,h+y,0}})
end
|
|
|
|
|
|
#38 |
![]() |
Yes, I've seen and posted in that thread, but that is simply discussing the pge and module parts - the function names (createcolor,startdrawing ,clearscreen) etc are not capitalized following the standard lua convention of capitalizing the first letter of each additional word after the first.
|
|
|
|
|
|
#42 |
![]() QJ Gamer Silver
|
Ummmhhh, this thread hasn't really been used in a while but i'd like to ask 1 question: What has been the best Lua game made??
taking in to account the code efficiency and gameplay. |
|
|
|
|
|
#44 |
![]() |
"lua modeller 3d."
That's not a game and was a mere 300 lines of code. If you're going by efficiency and how much the PSP is having to do to run the game, definitely Wedge Racer - play music, render walls and spaceships, do lots of math, and send data back and forth online - at 60 frames per second If you go by gameplay, probably Luamines and some stiff competition from the project I'm working on at the moment. |
|
|
|
|
|
#45 |
|
Banned for LIFE
|
|
|
|
|
|
|
#46 |
![]() |
I suppose so, but all it is doing is rendering some 3d stuff and then messing with some tables and numbers when some buttons are pressed. I'm sure it could be dropped to 200 lines or less.
Also, http://psp.metaclassofnil.com/crystalise/ Heavily rewritten luaplayer, the performance can't be wowed at because it uses OGL for the graphics and thus is much faster than luaplayer, but it is done with lua on the PSP with some of the same parts as the luaplayer we know today. Last edited by TurtlesPwn; 08-07-2008 at 09:41 AM.. |
|
|
|
|
|
#48 |
![]() QJ Gamer Green
|
I would precalc a sin table for things like jumping physics. google sin/cos lookup tables or something. that should give you what you need. Jumping is physics, its a sin wave. rapid rise, level off, descend.
__________________
-- Code Monkey : Sarien, Fishguts, Cracks and Crevices -- "Did IQ's just drop sharply while I was away?" (Ripley) |
|
|
|
|
|
#49 |
![]() |
Code:
math.sincache = {}
for i = 1, 180 do --don't need to go into then negatives if it's just for jumping up
math.sincache[i] = math.sin(i)
end
if jumpingTime >= 1 then
playerY = onFlatGroundY + math.sincache[jumpingTime]
if jumpingTime < 180 then
jumpingTime = jumpingTime + jumpingTimeIncrement
if jumpingTime > 180 then
jumpingTime = 0
end
end
elseif pad:cross() and not oldpad:cross() then
jumpingTime = 1
end
|
|
|
|
|
|
#51 |
![]() ![]() ![]() QJ Gamer Silver
|
Look at the jumping code from here: Lua Code Snippets I did a while back...
__________________
[Blog] [Portfolio] [Homebrew Illuminati - Serious Homebrew Development Forums] [I want to make Homebrew FAQ] [How I broke into the Games Industry] [Programming Book List] [Programming Article List] |
|
|
|
|
|
#52 | |
![]() QJ Gamer Silver
|
Quote:
They Only question on that Is The Bool_UpLastState, are they there to stop Double jumping? Why didn't you just use oldpad?
|
|
|
|
|
|
|
#53 |
![]() ![]() ![]() QJ Gamer Silver
|
They are there for the same reason as people use oldpad. At the time, I wasn't sure what the function calls for reading control input was doing under the hood.
The double jumping bug is still there is due to the code checking for a vertical velocity of 0 for being on the ground. |
|
|
|
|
|
#54 |
![]() |
It is basically an idea for a Shell that comes with the most popular Lua Games and can Launch them. Therefore it takes your favorite lua games and organizes them into 1 compact EBOOT. The Shell will be able to do other things such as USB connect and Play MP3s.
__________________
My Releases: --------------------------------------------------- [URL="http://forums.qj.net/showthread.php?t=145654"]ROFLFlasher[/URL] [URL="http://forums.qj.net/showthread.php?t=144892"]DTS MGS Edition[/URL] [URL="http://forums.qj.net/showthread.php?t=143735"]Arkanoid Deluxe Beta[/URL] [URL="http://forums.qj.net/showthread.php?p=2144700#post2144700"]SAVIOR![/URL] |
|
|
|
|
|
#55 |
![]() QJ Gamer Silver
Join Date: Sep 2006
Real First Name: Davee
Location: Perth, Scotland
Posts: 1,046
Trader Feedback: 0
|
There is already sooo many shells. There has to be one that does this already.
__________________
VSH Scramble Patcher || VSH Module Descrambler || Unlimted Character Version Changer (5.00) |
|
|
|
|
|
#56 |
![]() |
I've toyed around with making a "lua arcade" system before with a bunch of games and an interface to connect to a server to download more. i made it work and all but I never made it fancy or worth releasing. a similar system would probably be better because a generic shell in lua is not worth making
|
|
|
|
|
|
#57 | |
![]() |
Quote:
|
|
|
|
|
![]() |
| Tags |
| discussion , general , lua , thread |
| Thread Tools | |
|
|