“尖峰”分析器?

发布于 2024-09-14 20:26:39 字数 123 浏览 3 评论 0原文

我正在编写一个游戏,虽然它的性能在大多数情况下都很好,但有时会慢得像爬行一样。普通的分析器在这方面没有帮助,因为它们记录了我的游戏运行的整个时间,并且滞后部分中的重要信息在所有平滑部分中被稀释。是否有任何工具或库可以帮助我隔离问题?

I'm writing a game, and while it's performance is good most of the time, it sometimes slows to a crawl. Normal profilers haven't been a help in this, as they record the whole time my game is running, and the important info in the laggy portions get diluted over all of the smooth sections. Are there any tools or libraries that can help me isolate the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奢欲 2024-09-21 20:26:39

您几乎肯定会受到垃圾收集的影响。

是的,有一个工具可以解决这个问题。您需要CLR Profiler。这将准确地显示您正在分配内存的位置。

在 Xbox 上,垃圾收集器将在每分配 1MB 后运行,而且速度很慢。 Windows GC 的宽容度要高得多,但仍然会导致帧速率抖动。

避免垃圾收集卡顿的最佳方法是在游戏运行时不分配任何东西。在用户不会注意到的加载屏幕期间进行分配。

我建议阅读 这篇文章肖恩·哈格里夫斯博客上的这篇文章

You're almost certainly being hit by garbage collection.

And yes there is a tool for fixing that. You want the CLR Profiler. This will show you exactly where you're allocating memory.

On Xbox the garbage collector will run after every 1MB allocated and it is slow. The Windows GC is much more forgiving, but can still cause frame-rate jitter.

The best way to avoid garbage collection stutters is to not allocate anything while your game is running. Do your allocations during loading screens where the user won't notice.

I recommend reading this post and this post on Shawn Hargreaves' blog.

得不到的就毁灭 2024-09-21 20:26:39

你说你将从 16 毫秒的帧变成 3000 毫秒。因此,从长远来看,它花费了 (3000 - 16)/3000 = 99.5% 的时间来做你没有预料到的事情。

在这 3 秒内,你如何知道它在做什么?

只需暂停几次,然后检查调用堆栈即可。

不会看到它在每次暂停时正在做什么的可能性是 0.5%

如果它在垃圾收集器中,这应该可以确认它。如果它在做其他事情,它也会告诉你。

You say you're going from a frame taking 16ms to 3000ms. So in a long frame, it is spending (3000 - 16)/3000 = 99.5% of its time doing something you didn't expect.

During those 3 seconds, how can you find out what it's doing?

Just pause it a few times, and check the call stack.

The chance you won't see what it's doing on each pause is 0.5%

If it's in the garbage collector, this should confirm it. If it's doing something else, it will also tell you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文