Using Grid or Canvas as sprite containter?

Silverlight游戏性能测试
本文对比了使用Canvas和Grid作为精灵容器在Silverlight游戏开发中的性能表现,通过两个实例进行测试,结果显示两者在帧率和内存消耗方面表现相似。
31. January 2009 by Mads

The other day I were reading some great articles about creating a game step-by-step by Joel Neubeck. I looked at the source code and saw that he were placing his sprites different then what I have seen before. I wrote a comment to Joel on his blog. You can read it here.

Untill now I have only seen samples, and have also only done it this way myself, of placing sprites using a Canvas and the attached properties Canvas.Left and Canvas.Top. This have worked fine for others and for me.

By looking at Joels source code I saw that he were using a Grid as his container to hold his sprites and the a TranslateTransform to place them on the Grid.

Well, I know, the outcome is the same, but it made me think if there actually were a performance difference. So I desided to do a little test my self. I build two small Silverlight applications, both with the same content - balls bouncing around. One is using a Grid as the container and the other a Canvas.

image

You can see the samples live here:

Canvas sample

Grid sample

You can download the source code from here.

To me they look exactly the same. As you can see, if you run Firefox, that I have enabled the FrameRateCounter and have set the mas framerate to 9999. On my computer these are pretty much the same all the time. In Chrome I can see the memory useage of the silverlight plugin and that seems to be the same as well.

  • So, are they actually performing the same or am I testing this the wrong way?
  • Do you have any better way of testing this?
  • Does it perform differently on your computer?

Please let me know, as I think this is very good to know for all us game developers :)

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值