简体   繁体   English

衡量Android应用程序中Web服务的性能

[英]Measure performance of Web-services in Android Application

I want to measure time response (performance) of web services . 我想测量web services时间response (性能)。 I have an Android application to consume those services , and I want to register the time between a request and a response . 我有一个使用这些services的Android应用程序,我想注册一个request和一个response之间的时间。 Is there any form to do something like create and write in a text file those times? 那时候有什么形式可以做类似在文本文件中创建和写入的事情吗?

How can I do that? 我怎样才能做到这一点?

I'd suspect your making HTTP calls in your Android app. 我怀疑您在Android应用中进行HTTP调用。 As this factors in also network delays depending on where the server is located, all the intermediate devices (routers, network infrastructure, etc) and technology (3G vs wifi) it is not a very good indication of performance of your web-service. 由于这也取决于服务器所在的位置,所有中间设备(路由器,网络基础结构等)和技术(3G与wifi)的网络延迟,因此它并不是Web服务性能的很好指标。

Monitoring should be done server side in order to see variables such as the load, number of requests, memory usage, cpu utilization, etc. in addition to request logs. 应该在服务器端进行监视,以便除了查看请求日志以外,还可以查看变量,例如负载,请求数量,内存使用情况,cpu利用率等。

Specifically, what you can measure from your Application is: - Delay between the sending of the HTTP request, and the receiving of the response on your device. 具体来说,您可以从应用程序中衡量的是:-在设备上发送HTTP请求和接收响应之间的延迟。

If your only interested in calculating delay you can take the timestamp of when you make the request, and subtract it later on with the time stamp of when you receive a response. 如果您仅对计算延迟感兴趣,则可以记下发出请求的时间戳,然后在以后加上收到响应的时间戳记。 You can use System.System.currentTimeMillis() to get UNIX time in MS. 您可以使用System.System.currentTimeMillis()获取MS中的UNIX时间。 See: Time measuring overhead in Java 请参阅: Java时间测量开销

In order to actually measure performance of a webservice I would suggest: 为了实际衡量Web服务的性能,我建议:

  1. Running a monitoring application such as JMelody (Tomcat) on your webserver 在Web服务器上运行监视应用程序,例如JMelody(Tomcat)
  2. Simulating many requests using a tool such as JMeter 使用JMeter之类的工具模拟许多请求
  3. Profiling your algorithms 分析您的算法
  4. Checking many variables related to processing time, memory usage, etc. 检查许多与处理时间,内存使用量等有关的变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM