如何在 protobuf-net 中判断调用 DeserializeWithLengthPrefix 从 NetworkStream 读取了多少字节

发布于 2024-09-29 06:36:30 字数 176 浏览 0 评论 0原文

有办法做到这一点吗? 我想知道当我调用 DeserializeWithLengthPrefix 时从 NetworkStream 读取了多少字节。由于 NetworkStream 不支持 Position 属性,我看不到一种简单的方法来执行此操作。这可以以相当有效的方式完成吗? 我需要了解这一点以进行分析,并且最好将分析开销尽可能降低。

Is there a way to do this?
I would like to know how many bytes were read from a NetworkStream when I call DeserializeWithLengthPrefix. Since NetworkStream does not support the Position property I cannot see a simple way to do this. Can this be done in a reasonably efficient way?
I need to know this for profiling purposes, and it would be ideal to have the profiling overhead as low as possible.

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

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

发布评论

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

评论(1

╭ゆ眷念 2024-10-06 06:36:30

哦,这是一个很好的问题。目前尚未公开,但如果需要,我可以使用 out bytesRead 添加一个重载(以包括 lentgh 前缀和对象本身的开销,因为两者均已消耗)。我试图避免对“v1”进行太多更改,但我当然可以将其添加到“v2”中,而无需太多麻烦。

Oh, that is an excellent question. That isn't currently exposed, but if desired I could add an overload with an out bytesRead (to include both the overhead of the lentgh-prefix and the object itself, since both have been consumed). I'm trying to avoid too many changes to "v1", but I could certainly add that into "v2" without too much bother.

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