优化应用程序性能 [英] Optimizing application performance

查看:94
本文介绍了优化应用程序性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


不确定这是否是正确的问题,但这里有:


我是目前正在使用客户端 - 服务器模型来完成以下任务:


- 服务器从摄像头抓取图像并将其存储在磁盘上。

- 服务器应用程序与抓取器软件对话并获取位图文件的绝对路径。

- 客户端向服务器应用程序询问图像并以jpeg格式获取。


这背后的想法是通过足够快地传递图像来模拟视频流。目前我遇到了以下问题:


- FPS只有2,我认为我在TCP流量中失去了很多开销。

- 服务器负载达到100%。我相信改变位图 - > jpeg吸收了所有可用资源。


我基本上正在寻找有关图像处理和客户端 - 服务器架构的指南或信息。该应用程序是用C#编写的,并且依赖于.NET 4.0。

我可以提供测试应用程序或部分代码。

Hello,

not really sure if this is the correct place to ask this, but here goes:

I''m currently working on an application that uses the client-server model to accomplish the following:

- The server grabs images from camera''s and stores them on disk.
- The server application talks to the grabber software and obtains the absolute path to the bitmap files.
- The client asks the server application for an image and gets it in jpeg.

The idea behind this is to simulate a videostream by delivering the images in sequence fast enough. Currently I''m encountering the following issues:

- FPS is only 2, I think i''m loosing alot of overhead in the TCP traffic.
- Server goes up to 100% load. My believe is that the altering of bitmap -> jpeg sucks up all available resources.

I''m basicly looking for some guides or information about image processing and client-server architecture. The application is written in C# and relies in .NET 4.0.
I can provide the test application or parts of the code.

展开 | 选择 | Wrap | 行号

推荐答案

好吧,如果服务器负载是100%,我几乎可以保证你的2FPS不是由于TCP / IP开销造成的。


你可以做几件事

1)你可以预先将位图转换成jpeg图像

2)你可以发送未转换的位图


否则,你应该买一个现成的包装已经完成了。


祝你好运!
Well, if the server load is 100%, I can almost guarantee that your 2FPS is not due to TCP/IP overhead.

There are a couple things you can do
1) You can pre-convert the bitmaps to jpeg images
2) You can send unconverted bitmaps

Otherwise, you should just buy an off-the-shelf package and have done with.

Good Luck!


在优化方面,我看到的一个想法是确保你正在解决正确的问题。


我要做的第一件事就是创建一个基本的日志类,可用于记录程序的特定部分的时间长度采取。现在你猜测TCP / IP开销和图像转换正在扼杀你的FPS,但这只是猜测。你的程序也有文件i / o,这可能很慢,并且它正在幕后执行一堆框架代码。您可能会对吃掉处理时间感到惊讶。


所有这些都是猜测,直到您进行一些诊断以找出实际花费的时间。我不想将我的图像转换代码优化为死亡,只是发现我的.Net Framework TCP / IP设置导致性能不佳。
When it comes to optimization one of the ideas that I see coming up all the time is to make sure you are solving the right problem.

One of the first things that I would do is create a basic logging class that can be used to log how long specific portions of your program take. Right now you are guessing that the TCP/IP overhead and image conversion is what is killing your FPS, but that is just a guess. Your program also has file i/o, which can be slow, and it is executing a bunch of framework code behind the scenes. You may be surprised what is eating your processing time.

All of these are guesses until you do some diagnostics to find out where your time is actually being spent. I wouldn''t want to optimize my image conversion code to death only to find out that I had a .Net Framework TCP/IP setting that caused poor performance.


我的所有速度和放大器;愚蠢我忘了在某些函数中添加Thread.Sleep调用,因为Thread没有什么可做的....


现在CPU负载已减少到0:)

我现在只有其他问题,就是睡眠线程弄乱了我的TCP通信,因为它们的响应速度不够快。


猜猜我会必须改变协议中的一点,使其更多的是事件驱动而不是线性消息。
In all my quickness & sillyness I forgot to add Thread.Sleep calls in certain functions for what a Thread has nothing to do....

Now the CPU load has been reduced to 0 :)
Only other problem I have now, is that the sleeping threads mess up my TCP communication, because they don''t respond fast enough.

Guess I''ll have to change a bit in the protocol and make it more event driven instead of linear messages.


这篇关于优化应用程序性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆